Skip to content

Commit

Permalink
Fix conditions that always evaluate to false
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenneg committed Nov 5, 2019
1 parent a69d94e commit 74ed236
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

storedMethodCall.returnedProxy = instance.proxy;
storedMethodCall.proxyId = instance.key;
Expand Down
51 changes: 20 additions & 31 deletions devtools/maven/src/main/java/io/quarkus/maven/AddExtensionMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,41 +49,30 @@ protected void validateParameters() throws MojoExecutionException {
@Override
public void doExecute(BuildFile buildFile) throws MojoExecutionException {

boolean closeBuildFile = false;
try {
if (buildFile == null) {
try {
buildFile = BuildTool.MAVEN.createBuildFile(new FileProjectWriter(project.getBasedir()));
} catch (IOException e) {
throw new MojoExecutionException("Failed initialize project configuration tools", e);
}
}
Set<String> ext = new HashSet<>();
if (extensions != null && !extensions.isEmpty()) {
ext.addAll(extensions);
} else {
// Parse the "extension" just in case it contains several comma-separated values
// https://github.com/quarkusio/quarkus/issues/2393
ext.addAll(Arrays.stream(extension.split(",")).map(s -> s.trim()).collect(Collectors.toSet()));
}

if (buildFile == null) {
try {
final AddExtensionResult result = new AddExtensions(buildFile)
.addExtensions(ext.stream().map(String::trim).collect(Collectors.toSet()));
if (!result.succeeded()) {
throw new MojoExecutionException("Unable to add extensions");
}
buildFile = BuildTool.MAVEN.createBuildFile(new FileProjectWriter(project.getBasedir()));
} catch (IOException e) {
throw new MojoExecutionException("Unable to update the pom.xml file", e);
throw new MojoExecutionException("Failed to initialize the project's build descriptor", e);
}
} finally {
if (closeBuildFile && buildFile != null) {
try {
buildFile.close();
} catch (IOException e) {
getLog().debug("Failed to close " + buildFile, e);
}
}
Set<String> ext = new HashSet<>();
if (extensions != null && !extensions.isEmpty()) {
ext.addAll(extensions);
} else {
// Parse the "extension" just in case it contains several comma-separated values
// https://github.com/quarkusio/quarkus/issues/2393
ext.addAll(Arrays.stream(extension.split(",")).map(s -> s.trim()).collect(Collectors.toSet()));
}

try {
final AddExtensionResult result = new AddExtensions(buildFile)
.addExtensions(ext.stream().map(String::trim).collect(Collectors.toSet()));
if (!result.succeeded()) {
throw new MojoExecutionException("Unable to add extensions");
}
} catch (IOException e) {
throw new MojoExecutionException("Unable to update the pom.xml file", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
details = generateHeaderMessage(exception, uuid);
stack = generateStackTrace(exception);

} else if (uuid != null) {
} else {
details += "Error id " + uuid;
}
if (event.failure() instanceof IOException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
return "password=" + password + "; expected: " + expectedPassword;
}

Expand Down

0 comments on commit 74ed236

Please sign in to comment.