Skip to content

Commit

Permalink
[SpotBugs][pulsar-io]Enable spotbugs for pulsar-io-aws and pulsar-io-…
Browse files Browse the repository at this point in the history
…aerospike (apache#8842)

Fixes https://github.com/streamnative/pulsar/issues/1796, apache#8843


### Motivation

* This is a start, enable spotbugs for the pulsar-io module.

### Modifications

* Enable spotbugs for pulsar-io-aws and pulsar-io-aerospike
  • Loading branch information
tuteng authored Dec 7, 2020
1 parent 78c8e32 commit fd42512
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 3 deletions.
21 changes: 21 additions & 0 deletions pulsar-io/aerospike/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,27 @@
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-nar-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs-maven-plugin.version}</version>
<executions>
<execution>
<id>spotbugs</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<excludeFilterFile>${basedir}/src/main/resources/findbugsExclude.xml</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private void createClient(NioEventLoops eventLoops) {
Host[] aeroSpikeHosts = new Host[hosts.length];
for (int i = 0; i < hosts.length; ++i) {
String[] hostPort = hosts[i].split(":");
aeroSpikeHosts[i] = new Host(hostPort[0], Integer.valueOf(hostPort[1]));
aeroSpikeHosts[i] = new Host(hostPort[0], Integer.parseInt(hostPort[1]));
}
ClientPolicy policy = new ClientPolicy();
if (aerospikeSinkConfig.getUserName() != null && !aerospikeSinkConfig.getUserName().isEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.pulsar.functions.api.Record;
import org.apache.pulsar.io.core.KeyValue;
import java.nio.charset.StandardCharsets;

/**
* Aerospike sink that treats incoming messages on the input topic as Strings
Expand All @@ -29,7 +30,7 @@
public class AerospikeStringSink extends AerospikeAbstractSink<String, String> {
@Override
public KeyValue<String, String> extractKeyValue(Record<byte[]> record) {
String key = record.getKey().orElseGet(() -> new String(record.getValue()));
return new KeyValue<>(key, new String(record.getValue()));
String key = record.getKey().orElseGet(() -> new String(record.getValue(), StandardCharsets.UTF_8));
return new KeyValue<>(key, new String(record.getValue(), StandardCharsets.UTF_8));
}
}
22 changes: 22 additions & 0 deletions pulsar-io/aerospike/src/main/resources/findbugsExclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
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>
</FindBugsFilter>
26 changes: 26 additions & 0 deletions pulsar-io/aws/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,30 @@
<!-- /aws dependencies -->

</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs-maven-plugin.version}</version>
<executions>
<execution>
<id>spotbugs</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<excludeFilterFile>${basedir}/src/main/resources/findbugsExclude.xml</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</build>
</project>
22 changes: 22 additions & 0 deletions pulsar-io/aws/src/main/resources/findbugsExclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
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>
</FindBugsFilter>

0 comments on commit fd42512

Please sign in to comment.