GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [MPIR-478] Allow to save avatars images for team report during project build by slawekjaranowski · Pull Request #97 · apache/maven-project-info-reports-plugin

Conversation

@slawekjaranowski

@slawekjaranowski slawekjaranowski commented Feb 19, 2025

Copy link
Copy Markdown
Member

https://issues.apache.org/jira/browse/MPIR-478

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@slawekjaranowski
slawekjaranowski requested review from Bukama, elharo, hboutemy and michael-o February 19, 2025 22:34
@slawekjaranowski slawekjaranowski added the enhancement New feature or request label Feb 19, 2025
elharo
elharo requested changes Feb 19, 2025
View reviewed changes
Comment thread src/main/java/org/apache/maven/report/projectinfo/TeamReport.java Outdated
email = StringUtils.trim(email);
email = email.toLowerCase();
MessageDigest md;
private String getExternalAvatarUrl(String email) {

@elharo elharo Feb 19, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just throw IOException

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@slawekjaranowski slawekjaranowski Feb 19, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used in renderTeamMember and next in renderBody method.

  • renderBody method is implementation of org.apache.maven.reporting.AbstractMavenReportRenderer
  • renderBody can not throw any exception

so when exception should be catch and what we can do with it ...?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@elharo elharo Feb 19, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't handle the exception, just pretends it's not going to happen. Checked or unchecked it needs to be handled. I don't think it can be handled here, so throw the IOException and handle a failure where it's called from.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@slawekjaranowski slawekjaranowski Feb 20, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, what should happen on such exception, how do you want to handle it in report?

Now it be handled by Maven itself and build will be break.
I hope it will not often exception.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@elharo elharo Feb 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If breaking the build is the right answer — though I'm not sure it is — then that should happen higher up, likely with a MavenReportException or something like that. It shouldn't be a runtime exception from deep inside the code, whihc would indicate a bug in the code. An avatar service being unreachable is not a bug in the code, so just use a regular IOException here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@slawekjaranowski slawekjaranowski Feb 20, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from team report perspective fetching images can be interpreted as one of report feature - so it can be important

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@slawekjaranowski slawekjaranowski Feb 20, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renderBody method is defined in AbstractMavenReportRenderer from maven-reporting-impl so can not be changed in this PR.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@elharo elharo Feb 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't sound right. This is a private method so something in this class should be calling it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@slawekjaranowski slawekjaranowski Feb 20, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is use, line 279:

         picUrl = getExternalAvatarUrl(member.getEmail());

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@elharo elharo Feb 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so handle the IOException there, not here.

Also, if renderBody cannot throw any exception, then don't throw an exception in renderBody. Make sure that whatever code you call inside renderBody does not throw any exception, runtime exceptions included. Instead call all the code that might throw exceptions before you ever call renderBody, load up all the URLs or pics or whatever in memory at the beginning of executeReport, and only start rendering once all the resources are loaded and will not throw any exceptions during rendering.

Though in this case I really think it's simpler and easier to just use the default spacer image.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/org/apache/maven/report/projectinfo/TeamReport.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/main/java/org/apache/maven/report/projectinfo/TeamReport.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/main/java/org/apache/maven/report/projectinfo/TeamReport.java Outdated
private boolean showAvatarImages;

/**
* Indicate if external url should be used for avatar images.

@elharo elharo Feb 19, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URL.
Is there an internal URL? If not, delete "external" here or rewrite

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@slawekjaranowski slawekjaranowski Feb 19, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've rewritten a little here ...

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/org/apache/maven/report/projectinfo/avatars/AvatarsProvider.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/main/java/org/apache/maven/report/projectinfo/avatars/AvatarsProvider.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@slawekjaranowski
slawekjaranowski force-pushed the MPIR-478 branch 2 times, most recently from 498a69e to 925a45f Compare February 19, 2025 23:07
@slawekjaranowski
slawekjaranowski requested a review from elharo February 19, 2025 23:08
elharo
elharo requested changes Feb 19, 2025
View reviewed changes
Comment thread src/main/java/org/apache/maven/report/projectinfo/TeamReport.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/main/java/org/apache/maven/report/projectinfo/TeamReport.java Outdated
email = StringUtils.trim(email);
email = email.toLowerCase();
MessageDigest md;
private String getExternalAvatarUrl(String email) {

@elharo elharo Feb 19, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't handle the exception, just pretends it's not going to happen. Checked or unchecked it needs to be handled. I don't think it can be handled here, so throw the IOException and handle a failure where it's called from.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/org/apache/maven/report/projectinfo/TeamReport.java Outdated
}
if (picUrl == null || picUrl.isEmpty()) {
picUrl = getSpacerGravatarUrl();
picUrl = getExternalAvatarUrl(member.getEmail());

@elharo elharo Feb 19, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you want to do here when getExternalAvatarUrl( fails and throws an exception? Probably just don't call sink.figureGraphics below.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@slawekjaranowski slawekjaranowski Feb 20, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want break a build, because images in report can be missing.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@elharo elharo Feb 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if a user doesn't have an avatar? I don't think I do, for instance.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@slawekjaranowski slawekjaranowski Feb 20, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when user doesn't have an avatar default one will be returned by gravatar

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@elharo elharo Feb 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you can handle the IOException in this method. It doesn't need tonescape this class. Just wrap lines 277 through 285 in a try-catch block. The catch block can be empty or it can fill in a default image.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@slawekjaranowski slawekjaranowski Feb 20, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that I can catch and skip exception, and use default images - but I don't want.

As you know one step of release new component is publishing new documentation ... I don't want to add next manual task to verify team page during release. Maybe you have another experience with releasing new components ...

Some context of change - look at our team pages: https://maven.apache.org/team.html the same are on many other ASF projects.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
elharo
elharo requested changes Feb 20, 2025
View reviewed changes
Comment thread src/main/java/org/apache/maven/report/projectinfo/TeamReport.java
public void executeReport(Locale locale) throws MavenReportException {
AvatarsProvider avatarsProvider = avatarsProviders.get(avatarProviderName);
if (avatarsProvider == null) {
throw new MavenReportException("No AvatarsProvider found for name " + avatarProviderName);

@elharo elharo Feb 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to instead simply not show avatars in the report?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@slawekjaranowski slawekjaranowski Feb 20, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user want to show avatars, and probably misconfigured plugin - so we should not hide such case

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@elharo elharo Feb 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest message then, and not breaking the report. You could also add a default image used when the server can't be reached.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@slawekjaranowski slawekjaranowski Feb 20, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is two different case wrong configuration - not existing provider and not available image server.

In both case we should break a build to prevent of unwanted result

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/org/apache/maven/report/projectinfo/avatars/GravatarProvider.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@slawekjaranowski
slawekjaranowski force-pushed the MPIR-478 branch from 925a45f to 766300c Compare February 20, 2025 09:09
@slawekjaranowski
slawekjaranowski requested a review from elharo February 20, 2025 09:10
elharo
elharo requested changes Feb 20, 2025
View reviewed changes
Comment thread src/main/java/org/apache/maven/report/projectinfo/TeamReport.java
public void executeReport(Locale locale) throws MavenReportException {
AvatarsProvider avatarsProvider = avatarsProviders.get(avatarProviderName);
if (avatarsProvider == null) {
throw new MavenReportException("No AvatarsProvider found for name " + avatarProviderName);

@elharo elharo Feb 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest message then, and not breaking the report. You could also add a default image used when the server can't be reached.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/org/apache/maven/report/projectinfo/TeamReport.java Outdated
}
if (picUrl == null || picUrl.isEmpty()) {
picUrl = getSpacerGravatarUrl();
picUrl = getExternalAvatarUrl(member.getEmail());

@elharo elharo Feb 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if a user doesn't have an avatar? I don't think I do, for instance.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/org/apache/maven/report/projectinfo/TeamReport.java Outdated
email = StringUtils.trim(email);
email = email.toLowerCase();
MessageDigest md;
private String getExternalAvatarUrl(String email) {

@elharo elharo Feb 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If breaking the build is the right answer — though I'm not sure it is — then that should happen higher up, likely with a MavenReportException or something like that. It shouldn't be a runtime exception from deep inside the code, whihc would indicate a bug in the code. An avatar service being unreachable is not a bug in the code, so just use a regular IOException here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
elharo
elharo requested changes Feb 20, 2025
View reviewed changes
Comment thread src/main/java/org/apache/maven/report/projectinfo/TeamReport.java Outdated
email = StringUtils.trim(email);
email = email.toLowerCase();
MessageDigest md;
private String getExternalAvatarUrl(String email) {

@elharo elharo Feb 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not fetching an artifact is far more serious than not fetching a user pic. It's reasonable that one breaks the build and the other doesn't.

If you can't throw MavenReportException from renderBody then pass the IOException up the stack to something that can. Or change the method signature so it can throw, though here I really think the exception can simply be handled by dropping the image. Perhaps this exception can be handled by using the default image.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
elharo
elharo requested changes Feb 20, 2025
View reviewed changes
Comment thread src/main/java/org/apache/maven/report/projectinfo/TeamReport.java Outdated
email = StringUtils.trim(email);
email = email.toLowerCase();
MessageDigest md;
private String getExternalAvatarUrl(String email) {

@elharo elharo Feb 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't sound right. This is a private method so something in this class should be calling it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
elharo
elharo requested changes Feb 20, 2025
View reviewed changes
Comment thread src/main/java/org/apache/maven/report/projectinfo/TeamReport.java Outdated
}
if (picUrl == null || picUrl.isEmpty()) {
picUrl = getSpacerGravatarUrl();
picUrl = getExternalAvatarUrl(member.getEmail());

@elharo elharo Feb 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you can handle the IOException in this method. It doesn't need tonescape this class. Just wrap lines 277 through 285 in a try-catch block. The catch block can be empty or it can fill in a default image.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@slawekjaranowski
slawekjaranowski requested a review from elharo February 20, 2025 17:06
elharo
elharo requested changes Feb 20, 2025
View reviewed changes
Comment thread src/main/java/org/apache/maven/report/projectinfo/avatars/GravatarProvider.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/main/java/org/apache/maven/report/projectinfo/avatars/GravatarProvider.java
}
}

private String getSpacerGravatarUrl() {

@elharo elharo Feb 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably make this non-private and use this in cases where the provider fails.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/org/apache/maven/report/projectinfo/TeamReport.java Outdated
email = StringUtils.trim(email);
email = email.toLowerCase();
MessageDigest md;
private String getExternalAvatarUrl(String email) {

@elharo elharo Feb 20, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so handle the IOException there, not here.

Also, if renderBody cannot throw any exception, then don't throw an exception in renderBody. Make sure that whatever code you call inside renderBody does not throw any exception, runtime exceptions included. Instead call all the code that might throw exceptions before you ever call renderBody, load up all the URLs or pics or whatever in memory at the beginning of executeReport, and only start rendering once all the resources are loaded and will not throw any exceptions during rendering.

Though in this case I really think it's simpler and easier to just use the default spacer image.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@slawekjaranowski
slawekjaranowski force-pushed the MPIR-478 branch 2 times, most recently from bdf357c to db8f78f Compare February 20, 2025 21:53
@slawekjaranowski
slawekjaranowski requested a review from elharo February 20, 2025 22:03
@slawekjaranowski

slawekjaranowski commented Feb 20, 2025

Copy link
Copy Markdown
Member Author

@elharo please look now

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

elharo
elharo approved these changes Feb 21, 2025
View reviewed changes
@slawekjaranowski
[MPIR-478] Allow to save avatars images for team report during projec…
7cc46ad
…t build
@slawekjaranowski
slawekjaranowski force-pushed the MPIR-478 branch from db8f78f to 7cc46ad Compare February 22, 2025 11:04
@slawekjaranowski

slawekjaranowski commented Feb 22, 2025

Copy link
Copy Markdown
Member Author

Added support for default images in case of IOException or not existing avatar for given email

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@slawekjaranowski
slawekjaranowski requested a review from elharo February 22, 2025 11:05
Bukama
Bukama approved these changes Feb 22, 2025
View reviewed changes
Comment thread src/main/java/org/apache/maven/report/projectinfo/avatars/GravatarProvider.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

slachiewicz
slachiewicz approved these changes Feb 23, 2025
View reviewed changes
@slawekjaranowski slawekjaranowski self-assigned this Feb 23, 2025
@slawekjaranowski slawekjaranowski added this to the 3.9.0 milestone Feb 23, 2025
@slawekjaranowski
slawekjaranowski merged commit e51cef8 into apache:master Feb 23, 2025
@slawekjaranowski
slawekjaranowski deleted the MPIR-478 branch February 23, 2025 15:17
@jira-importer

jira-importer commented Jun 15, 2025

Copy link
Copy Markdown

Resolve #327

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

1 similar comment
@jira-importer

jira-importer commented Jun 15, 2025

Copy link
Copy Markdown

Resolve #327

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Bukama Bukama Bukama approved these changes
@slachiewicz slachiewicz slachiewicz approved these changes
@michael-o michael-o Awaiting requested review from michael-o
@hboutemy hboutemy Awaiting requested review from hboutemy
@elharo elharo Awaiting requested review from elharo

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@slawekjaranowski slawekjaranowski

Labels

enhancement New feature or request

Projects

None yet

Milestone

3.9.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@slawekjaranowski @jira-importer @elharo @Bukama @slachiewicz
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.