jacek-lewandowski commented on code in PR #2064:
URL: https://github.com/apache/cassandra/pull/2064#discussion_r1072081121


##########
src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java:
##########
@@ -907,43 +907,18 @@ public SSTableReader cloneWithNewStart(DecoratedKey 
newStart, final Runnable run
             // TODO: merge with caller's firstKeyBeyond() work,to save time
             if (newStart.compareTo(first) > 0)
             {
-                final long dataStart = getPosition(newStart, Operator.EQ);
-                final long indexStart = getIndexScanPosition(newStart);
-                this.tidy.runOnClose = new DropPageCache(dfile, dataStart, 
ifile, indexStart, runOnClose);
+                Map<FileHandle, Long> handleAndPositions = new 
LinkedHashMap<>(2);
+                if (dfile != null)
+                    handleAndPositions.put(dfile, getPosition(newStart, 
Operator.EQ));
+                if (ifile != null)
+                    handleAndPositions.put(ifile, 
getIndexScanPosition(newStart));
+                runOnClose(() -> 
handleAndPositions.forEach(FileHandle::dropPageCache));

Review Comment:
   I hope this will convince you:
   
   ```java
           class SomeUnserializableClass {
               public String a = "x";
               public byte[] serialize(String s) {
                   return SerializationUtils.serialize((Supplier<String> & 
Serializable) () -> {
                       return s + "#" + s + a;
                   });
               }
           }
   
           SomeUnserializableClass serializer = new SomeUnserializableClass();
           byte[] serialized = serializer.serialize("abc");
           Supplier<String> deseraizlied = 
SerializationUtils.deserialize(serialized);
           assertEquals("abc#abc", deseraizlied.get());
   ```
   
   this test indeed does not work because of `NotSerializableException` - we 
try to access `a` in lambda, which requires serialization of 
`SomeUnserializableClass`. 
   
   When `a` is removed, so that we just have:
   
   ```java
   return s + "#" + s;
   ```
   
   in lambda, test tests passes.
   
   
   



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to