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

Fix conditions that always evaluate to false #5188

Merged
merged 1 commit into from
Nov 8, 2019

Conversation

gwenneg
Copy link
Member

@gwenneg gwenneg commented Nov 4, 2019

No description provided.

}
} finally {
Copy link
Member Author

@gwenneg gwenneg Nov 4, 2019

Choose a reason for hiding this comment

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

@aloubyansky I need you to take a look at this one (hide whitespace changes for a much smaller diff). Right now, removing this code doesn't change the plugin behaviour, but I'm pretty sure that's not the way we'd want to fix this class.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it's not about just fixing this class, it's about fixing the tools. I think it's ok to merge it. The buildFile is closed in AddExtensions.

@@ -46,10 +46,10 @@ public void handle(RoutingContext event) {
String stack = "";
Throwable exception = event.failure();
if (showStack && exception != null) {
details = generateHeaderMessage(exception, uuid == null ? null : uuid.toString());
Copy link
Member Author

Choose a reason for hiding this comment

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

See line 44: String uuid = BASE_ID + ERROR_COUNT.incrementAndGet();

@@ -256,8 +256,6 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
return null;
}
ProxyInstance instance = getProxyInstance(returnType);
if (instance == null)
return null;
Copy link
Member Author

Choose a reason for hiding this comment

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

getProxyInstance(returnType); never returns null.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sold on this one.

Copy link
Member Author

Choose a reason for hiding this comment

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

Unless I'm missing something, the only value that can be returned from getProxyInstance(returnType); comes from https://github.com/quarkusio/quarkus/blob/master/core/deployment/src/main/java/io/quarkus/deployment/recording/BytecodeRecorderImpl.java#L312-L313

Copy link
Member

Choose a reason for hiding this comment

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

It's not about missing something. It's just that doesn't cost anything to have it there so I would keep it.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's back with curly braces in bonus!

@gwenneg gwenneg requested a review from aloubyansky November 4, 2019 21:52
} catch (IOException e) {
throw new MojoExecutionException("Unable to update the pom.xml file", e);
throw new MojoExecutionException("Failed initialize project configuration tools", e);
Copy link
Contributor

@gastaldi gastaldi Nov 5, 2019

Choose a reason for hiding this comment

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

Suggested change
throw new MojoExecutionException("Failed initialize project configuration tools", e);
throw new MojoExecutionException("Failed to initialize the project's build descriptor", e);

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed, thanks for the suggestion!

@gwenneg gwenneg force-pushed the fix-always-false-conditions branch 2 times, most recently from 74ed236 to aa0680a Compare November 5, 2019 07:05
Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

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

I added a few comments.

@@ -39,7 +39,7 @@ public String test() {
return "someSecret=" + someSecret + "; expected: " + expectedPassword;
}
String password = ConfigProviderResolver.instance().getConfig().getValue("password", String.class);
if (!expectedPassword.equals(someSecret)) {
if (!password.equals(someSecret)) {
Copy link
Member

Choose a reason for hiding this comment

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

This one makes sense but @vsevel could you have a look?

Copy link
Contributor

@vsevel vsevel Nov 5, 2019

Choose a reason for hiding this comment

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

the second case should be between password and expectedPassword (not between password and someSecret) - although checking password against someSecret was already fixing the issue because we checked just before that someSecret is equal to expectedPassword

password and someSecret are calculated, expectedPassword is the reference (could be a constant)
so something like this is more appropriate:

        String password = ConfigProviderResolver.instance().getConfig().getValue("password", String.class);
        if (!expectedPassword.equals(password)) {
            return "password=" + password + "; expected: " + expectedPassword;
        }

thanks for catching that one.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @vsevel! I changed the code according to your suggestion.

stack = generateStackTrace(exception);

} else if (uuid != null) {
} else {
Copy link
Member

Choose a reason for hiding this comment

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

OK for these two.

@@ -256,8 +256,6 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
return null;
}
ProxyInstance instance = getProxyInstance(returnType);
if (instance == null)
return null;
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sold on this one.

@gwenneg gwenneg force-pushed the fix-always-false-conditions branch from aa0680a to 90f0001 Compare November 5, 2019 12:51
@gwenneg
Copy link
Member Author

gwenneg commented Nov 5, 2019

@gsmet It should be all good now.

@gwenneg
Copy link
Member Author

gwenneg commented Nov 8, 2019

@gastaldi Could you please do the approving review for this PR? I was waiting for @gsmet approval, but he's away for a few days and all changes have already been approved individually, so it shouldn't be a problem.

Copy link
Contributor

@gastaldi gastaldi left a comment

Choose a reason for hiding this comment

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

LGTM

@gastaldi gastaldi added this to the 1.1.0 milestone Nov 8, 2019
@gastaldi gastaldi merged commit 5fea8c0 into quarkusio:master Nov 8, 2019
@gwenneg gwenneg deleted the fix-always-false-conditions branch November 8, 2019 07:22
@gwenneg
Copy link
Member Author

gwenneg commented Nov 8, 2019

Thanks!

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.

5 participants