distributedlog-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject [1/2] incubator-distributedlog git commit: DL-32: Fix Findbug warnings
Date Thu, 13 Oct 2016 07:47:16 GMT
Repository: incubator-distributedlog
Updated Branches:
  refs/heads/master 93bdad0ea -> bb6990dee


http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/bb6990de/distributedlog-service/src/main/resources/findbugsExclude.xml
----------------------------------------------------------------------
diff --git a/distributedlog-service/src/main/resources/findbugsExclude.xml b/distributedlog-service/src/main/resources/findbugsExclude.xml
index 050d54b..502befa 100644
--- a/distributedlog-service/src/main/resources/findbugsExclude.xml
+++ b/distributedlog-service/src/main/resources/findbugsExclude.xml
@@ -26,4 +26,10 @@
     <Method name="onFailure" />
     <Bug pattern="BC_UNCONFIRMED_CAST" />
   </Match>
+  <Match>
+    <!-- it is safe to cast exception here. //-->
+    <Class name="com.twitter.distributedlog.service.stream.BulkWriteOp" />
+    <Method name="isDefiniteFailure" />
+    <Bug pattern="BC_IMPOSSIBLE_INSTANCEOF" />
+  </Match>
 </FindBugsFilter>

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/bb6990de/distributedlog-tutorials/distributedlog-basic/pom.xml
----------------------------------------------------------------------
diff --git a/distributedlog-tutorials/distributedlog-basic/pom.xml b/distributedlog-tutorials/distributedlog-basic/pom.xml
index b0f16ae..6cb412f 100644
--- a/distributedlog-tutorials/distributedlog-basic/pom.xml
+++ b/distributedlog-tutorials/distributedlog-basic/pom.xml
@@ -58,13 +58,6 @@
   <build>
     <plugins>
       <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>findbugs-maven-plugin</artifactId>
-        <configuration>
-          <excludeFilterFile>${basedir}/src/main/resources/findbugsExclude.xml</excludeFilterFile>
-        </configuration>
-      </plugin>
-      <plugin>
         <artifactId>maven-dependency-plugin</artifactId>
         <executions>
           <execution>

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/bb6990de/distributedlog-tutorials/distributedlog-basic/src/main/java/com/twitter/distributedlog/basic/ConsoleProxyMultiWriter.java
----------------------------------------------------------------------
diff --git a/distributedlog-tutorials/distributedlog-basic/src/main/java/com/twitter/distributedlog/basic/ConsoleProxyMultiWriter.java
b/distributedlog-tutorials/distributedlog-basic/src/main/java/com/twitter/distributedlog/basic/ConsoleProxyMultiWriter.java
index 42d0490..f9d245c 100644
--- a/distributedlog-tutorials/distributedlog-basic/src/main/java/com/twitter/distributedlog/basic/ConsoleProxyMultiWriter.java
+++ b/distributedlog-tutorials/distributedlog-basic/src/main/java/com/twitter/distributedlog/basic/ConsoleProxyMultiWriter.java
@@ -25,7 +25,6 @@ import com.twitter.distributedlog.service.DistributedLogClientBuilder;
 import com.twitter.finagle.thrift.ClientId;
 import com.twitter.util.FutureEventListener;
 import jline.ConsoleReader;
-import jline.Terminal;
 import org.apache.commons.lang.StringUtils;
 
 import java.nio.ByteBuffer;
@@ -66,8 +65,6 @@ public class ConsoleProxyMultiWriter {
                 .requestTimeoutMs(50000)
                 .build();
 
-        // Setup Terminal
-        Terminal terminal = Terminal.setupTerminal();
         ConsoleReader reader = new ConsoleReader();
         String line;
         while ((line = reader.readLine(PROMPT_MESSAGE)) != null) {

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/bb6990de/distributedlog-tutorials/distributedlog-basic/src/main/java/com/twitter/distributedlog/basic/ConsoleProxyWriter.java
----------------------------------------------------------------------
diff --git a/distributedlog-tutorials/distributedlog-basic/src/main/java/com/twitter/distributedlog/basic/ConsoleProxyWriter.java
b/distributedlog-tutorials/distributedlog-basic/src/main/java/com/twitter/distributedlog/basic/ConsoleProxyWriter.java
index 51d5eb3..3e98b27 100644
--- a/distributedlog-tutorials/distributedlog-basic/src/main/java/com/twitter/distributedlog/basic/ConsoleProxyWriter.java
+++ b/distributedlog-tutorials/distributedlog-basic/src/main/java/com/twitter/distributedlog/basic/ConsoleProxyWriter.java
@@ -23,7 +23,6 @@ import com.twitter.distributedlog.service.DistributedLogClientBuilder;
 import com.twitter.finagle.thrift.ClientId;
 import com.twitter.util.FutureEventListener;
 import jline.ConsoleReader;
-import jline.Terminal;
 
 import java.nio.ByteBuffer;
 
@@ -53,8 +52,6 @@ public class ConsoleProxyWriter {
                 .finagleNameStr(finagleNameStr)
                 .build();
 
-        // Setup Terminal
-        Terminal terminal = Terminal.setupTerminal();
         ConsoleReader reader = new ConsoleReader();
         String line;
         while ((line = reader.readLine(PROMPT_MESSAGE)) != null) {

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/bb6990de/distributedlog-tutorials/distributedlog-basic/src/main/java/com/twitter/distributedlog/basic/ConsoleWriter.java
----------------------------------------------------------------------
diff --git a/distributedlog-tutorials/distributedlog-basic/src/main/java/com/twitter/distributedlog/basic/ConsoleWriter.java
b/distributedlog-tutorials/distributedlog-basic/src/main/java/com/twitter/distributedlog/basic/ConsoleWriter.java
index ba21821..549e84a 100644
--- a/distributedlog-tutorials/distributedlog-basic/src/main/java/com/twitter/distributedlog/basic/ConsoleWriter.java
+++ b/distributedlog-tutorials/distributedlog-basic/src/main/java/com/twitter/distributedlog/basic/ConsoleWriter.java
@@ -24,7 +24,6 @@ import com.twitter.distributedlog.util.FutureUtils;
 import com.twitter.util.Duration;
 import com.twitter.util.FutureEventListener;
 import jline.ConsoleReader;
-import jline.Terminal;
 
 import java.net.URI;
 import java.util.concurrent.TimeUnit;
@@ -70,8 +69,6 @@ public class ConsoleWriter {
             try {
                 writer = FutureUtils.result(dlm.openAsyncLogWriter());
 
-                // Setup Terminal
-                Terminal terminal = Terminal.setupTerminal();
                 ConsoleReader reader = new ConsoleReader();
                 String line;
                 while ((line = reader.readLine(PROMPT_MESSAGE)) != null) {

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/bb6990de/distributedlog-tutorials/distributedlog-kafka/pom.xml
----------------------------------------------------------------------
diff --git a/distributedlog-tutorials/distributedlog-kafka/pom.xml b/distributedlog-tutorials/distributedlog-kafka/pom.xml
index eca2052..843ac70 100644
--- a/distributedlog-tutorials/distributedlog-kafka/pom.xml
+++ b/distributedlog-tutorials/distributedlog-kafka/pom.xml
@@ -47,13 +47,6 @@
   <build>
     <plugins>
       <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>findbugs-maven-plugin</artifactId>
-        <configuration>
-          <excludeFilterFile>${basedir}/src/main/resources/findbugsExclude.xml</excludeFilterFile>
-        </configuration>
-      </plugin>
-      <plugin>
         <artifactId>maven-dependency-plugin</artifactId>
         <executions>
           <execution>

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/bb6990de/distributedlog-tutorials/distributedlog-kafka/src/main/java/com/twitter/distributedlog/kafka/DLFutureRecordMetadata.java
----------------------------------------------------------------------
diff --git a/distributedlog-tutorials/distributedlog-kafka/src/main/java/com/twitter/distributedlog/kafka/DLFutureRecordMetadata.java
b/distributedlog-tutorials/distributedlog-kafka/src/main/java/com/twitter/distributedlog/kafka/DLFutureRecordMetadata.java
index 69b73fc..1c6e432 100644
--- a/distributedlog-tutorials/distributedlog-kafka/src/main/java/com/twitter/distributedlog/kafka/DLFutureRecordMetadata.java
+++ b/distributedlog-tutorials/distributedlog-kafka/src/main/java/com/twitter/distributedlog/kafka/DLFutureRecordMetadata.java
@@ -79,7 +79,7 @@ class DLFutureRecordMetadata implements Future<RecordMetadata> {
     @Override
     public RecordMetadata get() throws InterruptedException, ExecutionException {
         try {
-            DLSN dlsn = FutureUtils.result(dlsnFuture);
+            FutureUtils.result(dlsnFuture);
             // TODO: align the DLSN concepts with kafka concepts
             return new RecordMetadata(new TopicPartition(topic, 0), -1L, -1L);
         } catch (DLInterruptedException e) {
@@ -92,7 +92,7 @@ class DLFutureRecordMetadata implements Future<RecordMetadata> {
     @Override
     public RecordMetadata get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException,
TimeoutException {
         try {
-            DLSN dlsn = FutureUtils.result(dlsnFuture, Duration.apply(timeout, unit));
+            FutureUtils.result(dlsnFuture, Duration.apply(timeout, unit));
             // TODO: align the DLSN concepts with kafka concepts
             return new RecordMetadata(new TopicPartition(topic, 0), -1L, -1L);
         } catch (DLInterruptedException e) {

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/bb6990de/distributedlog-tutorials/distributedlog-mapreduce/src/main/java/com/twitter/distributedlog/mapreduce/LogSegmentReader.java
----------------------------------------------------------------------
diff --git a/distributedlog-tutorials/distributedlog-mapreduce/src/main/java/com/twitter/distributedlog/mapreduce/LogSegmentReader.java
b/distributedlog-tutorials/distributedlog-mapreduce/src/main/java/com/twitter/distributedlog/mapreduce/LogSegmentReader.java
index 7a7dff0..6dfc6aa 100644
--- a/distributedlog-tutorials/distributedlog-mapreduce/src/main/java/com/twitter/distributedlog/mapreduce/LogSegmentReader.java
+++ b/distributedlog-tutorials/distributedlog-mapreduce/src/main/java/com/twitter/distributedlog/mapreduce/LogSegmentReader.java
@@ -42,7 +42,7 @@ class LogSegmentReader extends RecordReader<DLSN, LogRecordWithDLSN>
{
     final LogSegmentMetadata metadata;
 
     long entryId = -1L;
-    LogRecord.Reader reader = null;
+    Entry.Reader reader = null;
     LogRecordWithDLSN currentRecord = null;
     int readPos = 0;
 
@@ -79,13 +79,13 @@ class LogSegmentReader extends RecordReader<DLSN, LogRecordWithDLSN>
{
         LogRecordWithDLSN record;
         currentRecord = null;
         if (null != reader) {
-            record = reader.readOp();
+            record = reader.nextRecord();
             if (null != record) {
                 currentRecord = record;
                 readPos = record.getPositionWithinLogSegment();
                 return true;
             } else {
-                reader = null;
+                return false;
             }
         }
         ++entryId;
@@ -97,7 +97,7 @@ class LogSegmentReader extends RecordReader<DLSN, LogRecordWithDLSN>
{
                     lh.readEntries(entryId, entryId);
             if (entries.hasMoreElements()) {
                 LedgerEntry entry = entries.nextElement();
-                Entry.newBuilder()
+                reader = Entry.newBuilder()
                         .setLogSegmentInfo(metadata.getLogSegmentSequenceNumber(),
                                 metadata.getStartSequenceId())
                         .setEntryId(entry.getEntryId())

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/bb6990de/distributedlog-tutorials/distributedlog-messaging/src/main/java/com/twitter/distributedlog/messaging/ConsoleProxyPartitionedMultiWriter.java
----------------------------------------------------------------------
diff --git a/distributedlog-tutorials/distributedlog-messaging/src/main/java/com/twitter/distributedlog/messaging/ConsoleProxyPartitionedMultiWriter.java
b/distributedlog-tutorials/distributedlog-messaging/src/main/java/com/twitter/distributedlog/messaging/ConsoleProxyPartitionedMultiWriter.java
index 79ed576..73d153a 100644
--- a/distributedlog-tutorials/distributedlog-messaging/src/main/java/com/twitter/distributedlog/messaging/ConsoleProxyPartitionedMultiWriter.java
+++ b/distributedlog-tutorials/distributedlog-messaging/src/main/java/com/twitter/distributedlog/messaging/ConsoleProxyPartitionedMultiWriter.java
@@ -82,8 +82,6 @@ public class ConsoleProxyPartitionedMultiWriter {
                         new IntPartitioner(),
                         client);
 
-        // Setup Terminal
-        Terminal terminal = Terminal.setupTerminal();
         ConsoleReader reader = new ConsoleReader();
         String line;
         while ((line = reader.readLine(PROMPT_MESSAGE)) != null) {

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/bb6990de/distributedlog-tutorials/distributedlog-messaging/src/main/java/com/twitter/distributedlog/messaging/ConsoleProxyRRMultiWriter.java
----------------------------------------------------------------------
diff --git a/distributedlog-tutorials/distributedlog-messaging/src/main/java/com/twitter/distributedlog/messaging/ConsoleProxyRRMultiWriter.java
b/distributedlog-tutorials/distributedlog-messaging/src/main/java/com/twitter/distributedlog/messaging/ConsoleProxyRRMultiWriter.java
index 00398c1..c3b94ca 100644
--- a/distributedlog-tutorials/distributedlog-messaging/src/main/java/com/twitter/distributedlog/messaging/ConsoleProxyRRMultiWriter.java
+++ b/distributedlog-tutorials/distributedlog-messaging/src/main/java/com/twitter/distributedlog/messaging/ConsoleProxyRRMultiWriter.java
@@ -52,8 +52,6 @@ public class ConsoleProxyRRMultiWriter {
         String[] streamNameList = StringUtils.split(streamList, ',');
         RRMultiWriter<Integer, String> writer = new RRMultiWriter(streamNameList, client);
 
-        // Setup Terminal
-        Terminal terminal = Terminal.setupTerminal();
         ConsoleReader reader = new ConsoleReader();
         String line;
         while ((line = reader.readLine(PROMPT_MESSAGE)) != null) {

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/bb6990de/distributedlog-tutorials/distributedlog-messaging/src/main/resources/findbugsExclude.xml
----------------------------------------------------------------------
diff --git a/distributedlog-tutorials/distributedlog-messaging/src/main/resources/findbugsExclude.xml
b/distributedlog-tutorials/distributedlog-messaging/src/main/resources/findbugsExclude.xml
new file mode 100644
index 0000000..9cb253a
--- /dev/null
+++ b/distributedlog-tutorials/distributedlog-messaging/src/main/resources/findbugsExclude.xml
@@ -0,0 +1,33 @@
+<!--
+    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>
+    <!-- generated code, we can't be held responsible for findbugs in it //-->
+    <Class name="~.*\.TransformedRecord" />
+  </Match>
+  <Match>
+    <!-- it is safe to store external bytes reference here. //-->
+    <Class name="com.twitter.distributedlog.messaging.PartitionedMultiWriter" />
+    <Bug pattern="EI_EXPOSE_REP2" />
+  </Match>
+  <Match>
+    <!-- it is safe to store external bytes reference here. //-->
+    <Class name="com.twitter.distributedlog.messaging.RRMultiWriter" />
+    <Bug pattern="EI_EXPOSE_REP2" />
+  </Match>
+</FindBugsFilter>

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/bb6990de/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1b771a3..6441a26 100644
--- a/pom.xml
+++ b/pom.xml
@@ -81,7 +81,6 @@
     <module>distributedlog-client</module>
     <module>distributedlog-service</module>
     <module>distributedlog-benchmark</module>
-    <module>distributedlog-example</module>
     <module>distributedlog-tutorials</module>
   </modules>
   <properties>
@@ -132,7 +131,7 @@
       <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>findbugs-maven-plugin</artifactId>
-        <version>2.5.2</version>
+        <version>3.0.3</version>
       </plugin>
       <plugin>
         <artifactId>maven-compiler-plugin</artifactId>


Mime
View raw message