Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Java 7 related code improvement (20181027) #317

Closed
wants to merge 4 commits into from

Conversation

obfischer
Copy link
Contributor

Serveral minor improvements to the code base as usage of the diamond operator, simplified exception handling and removal of not need try-catch-statements for NullPointerExceptions.

@obfischer obfischer changed the title Java 7 update 20181027 More Java 7 related code improvement (20181027) Oct 27, 2018
Copy link
Contributor

@fabiojb fabiojb left a comment

Choose a reason for hiding this comment

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

Add some NullPointer error handling. More information on the comments

@@ -292,7 +292,8 @@ else if ( event.isEndElement() )
{
// we want only those parts of pluginManagement that are defined in this project
Map<String, String> pluginManagement = new HashMap<>();
try

if ( model.getBuild().getPluginManagement() != null )
{
for ( Plugin plugin : model.getBuild().getPluginManagement().getPlugins() )
Copy link
Contributor

Choose a reason for hiding this comment

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

You can still get NullPointers here, if model.getBuild().getPluginManagement().getPlugins() returns null.

As long as you removed the try/catch statement, I think there should be a nullity verfiy before the for loop, or put back the try/catch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I checked every getter if it could return null or not. A call to getPlugins() can never return null. Furthermore we would have a lot of NullPointerExceptions during the integration tests.

// guess there are no plugins here
}
try
for ( Profile profile : model.getProfiles() )
Copy link
Contributor

Choose a reason for hiding this comment

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

Same case here, you can still get NullPointers here, if model.getProfiles() returns null.

{
try
for ( Plugin plugin : profile.getBuild().getPluginManagement().getPlugins() )
Copy link
Contributor

@fabiojb fabiojb Nov 5, 2018

Choose a reason for hiding this comment

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

Same case here, you can still get NullPointers if profile.getBuild().getPluginManagement().getPlugins() returns null

@github-actions
Copy link

github-actions bot commented Jun 5, 2021

This PR is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Jun 5, 2021
@obfischer
Copy link
Contributor Author

Hi @fabiojb,

I would like to discuss this pull request again with you, if it is fine for you. When I did my first contribution to the Versions plugin, it was very hard for me to deal with the existing code base. The programming style reminded me of C and was very hard to read. I mean it was very hard to understand the logic. So the goal of this pull request was to make the code easier to read and to understand. Improving the code base would help to get new contributors and to ease the adding of new features.

I am looking forward to your answer and the dicussion with you.

@obfischer
Copy link
Contributor Author

I will close this PR and will start to work on a new one.

@obfischer obfischer closed this Jun 9, 2021
@fabiojb
Copy link
Contributor

fabiojb commented Jun 10, 2021

Hi @obfischer sorry for the delayed response. I can still review your code, but I cannot merge it, as I dont have the privileges to.

@obfischer
Copy link
Contributor Author

Hi @fabiojb, no problem at all. I will open an issue and would like to start a discussion how to modernize the code base of the plugin.

@bmarwell
Copy link
Contributor

@olamy is just doing this...

#463

I think you will have to rebase a lot after his PR is merged. Sorry we didn't aee yours earlier.

@obfischer obfischer deleted the java-7-update-20181027 branch June 26, 2021 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants