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

[Spotbugs] Enable spotbugs in pulsar-metadata #9253

Merged
merged 5 commits into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions pulsar-metadata/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,26 @@
<artifactId>caffeine</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs-maven-plugin.version}</version>
<configuration>
<excludeFilterFile>${basedir}/src/test/resources/findbugsExclude.xml</excludeFilterFile>
</configuration>
<executions>
<execution>
<id>spotbugs</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*/
@Data
public class GetResult {

/**
* The value of the key stored.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ private synchronized CompletableFuture<LeaderElectionState> elect() {
log.warn("Exception in state change listener", t);
}
}
return CompletableFuture.completedFuture(leaderElectionState);
}
return CompletableFuture.completedFuture(leaderElectionState);
} else {
return tryToBecomeLeader();
}
Expand Down Expand Up @@ -143,8 +143,8 @@ private synchronized CompletableFuture<LeaderElectionState> tryToBecomeLeader()
log.warn("Exception in state change listener", t);
}
}
result.complete(leaderElectionState);
}
result.complete(leaderElectionState);
}).exceptionally(ex -> {
// We fail to do the get(), so clean up the leader election fail the whole
// operation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public synchronized CompletableFuture<Void> storeDelete(String path, Optional<Lo
Value value = map.get(path);
if (value == null) {
return FutureUtils.exception(new NotFoundException(""));
} else if (value != null && optExpectedVersion.isPresent() && optExpectedVersion.get() != value.version) {
} else if (optExpectedVersion.isPresent() && optExpectedVersion.get() != value.version) {
return FutureUtils.exception(new BadVersionException(""));
} else {
map.remove(path);
Expand All @@ -191,6 +191,6 @@ private static boolean isValidPath(String path) {
return false;
}

return path != "/" || !path.endsWith("/");
return !path.equals("/") || !path.endsWith("/");
}
}
26 changes: 26 additions & 0 deletions pulsar-metadata/src/test/resources/findbugsExclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!--

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

-->
<FindBugsFilter>
<Match>
<Class name="org.apache.pulsar.metadata.api.GetResult" />
<Bug pattern="EI_EXPOSE_REP,EI_EXPOSE_REP2" />
</Match>
</FindBugsFilter>