EdColeman commented on a change in pull request #2324:
URL: https://github.com/apache/accumulo/pull/2324#discussion_r734588265



##########
File path: 
server/base/src/main/java/org/apache/accumulo/server/conf/store/PropCache.java
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+package org.apache.accumulo.server.conf.store;
+
+import org.apache.accumulo.server.conf.codec.VersionedProperties;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+public interface PropCache {
+
+  @Nullable

Review comment:
       The nullable annotation was used by Caffeine, but we also already had it 
as a dependency.  I started using it where Caffeine had it, and found it 
useful. With it, the build will fail, without the code can throw runtime, null 
pointer exception. A contrived sample:
   ```
   @Test
   public void maybeNull() {
     String s = getSomething().toString();
     log.info("A value: {}", s);
   }
   
   private @Nullable Long getSomething() {
     var ts = System.currentTimeMillis();
     if ((ts & 0x01L) == 0) {
       return null;
     }
     return Long.valueOf(System.currentTimeMillis());
   }
   ```
   With the annotation, the build fails with:
   ```
   [ERROR] Medium: Possible null pointer dereference in 
org.apache.accumulo.server.conf2.impl.XTest.maybeNull() due to return value of 
called method [org.apache.accumulo.server.conf2.impl.XTest, 
org.apache.accumulo.server.conf2.impl.XTest] Dereferenced at XTest.java:[line 
46]Known null at XTest.java:[line 46] NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE 
(edited) 
   ```
   
   If we find that usefully, I'd like to see us use it more.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to