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

PAYARA-3723 Fixing sonar blocker bugs with unclosed resources and potential NPE #3868

Merged
merged 3 commits into from
Apr 10, 2019

Conversation

svendiedrichsen
Copy link
Contributor

No description provided.

@Cousjava
Copy link
Contributor

Jenkins test please

@mulderbaba mulderbaba added this to the 5.192 milestone Mar 30, 2019
Copy link
Member

@Pandrex247 Pandrex247 left a comment

Choose a reason for hiding this comment

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

Looks fine to me, just some formatting niggles

import org.glassfish.appclient.client.acc.JWSACCClassLoader;
import org.glassfish.appclient.common.Util;

import javax.swing.*;
Copy link
Member

Choose a reason for hiding this comment

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

Minor point, but is this necessary? Aren't we only using one class from here?


private byte[] serialize(Object obj) throws IOException {
try(ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = getFactory().createObjectOutputStream(bos)) {
Copy link
Member

Choose a reason for hiding this comment

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

Formatting is a little off here, makes this a bit hard to read as this line looks like it belongs with the ones below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually 2 Closables in one try-with-resources block. To have them both automatically closed. I have made now 2 try blocks to make clearer.

return JsonbBuilder
.create()
.fromJson(objectValue.toString(), type);
try(Jsonb jsonb = JsonbBuilder.create()) {
Copy link
Member

Choose a reason for hiding this comment

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

Super minor, you missed a space between try and (

@@ -245,6 +243,12 @@ private AuthenticationStatus validateAuthorizationCode(HttpMessageContext httpCo
}
}

private JsonObject readJsonObject(String tokensBody) {
try(JsonReader reader = Json.createReader(new StringReader(tokensBody))) {
Copy link
Member

Choose a reason for hiding this comment

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

Same as other comment, just nitpicking formatting here

@svendiedrichsen
Copy link
Contributor Author

@Pandrex247 I have made the requested code changes.

@Cousjava
Copy link
Contributor

Cousjava commented Apr 9, 2019

Jenkins test please

@Pandrex247 Pandrex247 changed the title Fixing sonar blocker bugs with unclosed resources and potential NPE PAYARA-3723 Fixing sonar blocker bugs with unclosed resources and potential NPE Apr 10, 2019
@Pandrex247 Pandrex247 merged commit e797815 into payara:master Apr 10, 2019
@svendiedrichsen svendiedrichsen deleted the sonar-blocker-npe branch April 10, 2019 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants