Uploaded image for project: 'Apache Cassandra'
  1. Apache Cassandra
  2. CASSANDRA-18264

CustomClassLoader does not load jars rendering triggers from JARs broken

    XMLWordPrintableJSON

Details

    Description

      A user had to downgrade to 4.0.7 from 4.1.0 because they hit a problem with CustomClassLoader for triggers.

      User says that in Apache Cassandra 4.1.0 the trigger mechanism does not work, not their trigger, but the possibility of loading any trigger in Cassandra.

      In the Cassandra 4.1.0 version of CustomClassLoader (https://github.com/apache/cassandra/blob/cassandra-4.1/src/java/org/apache/cassandra/triggers/CustomClassLoader.java) the code is changed in such a way that when copying the JAR Cassandra uses java.nio.file.Files, while earlier versions (cassandra 4.0.X or 3.X) used Guava com.google.common.io.Files to copy the JAR file.

      The difference between one and the other is that Guava by default overwrites the file if it already exists and user has permissions to do so, and in Java by default it does not overwrite.

      Copying is done here (1) from inputJar to out. However, the problem is that we are getting temporary file from here (2) and the implementation loops unless it succeeds to create an empty file. (3) - But that fails to copy the file to out because copying does not work when the target file already exists.

      (1) https://github.com/apache/cassandra/blob/cassandra-4.1/src/java/org/apache/cassandra/triggers/CustomClassLoader.java#L86

      (2) https://github.com/apache/cassandra/blob/cassandra-4.1/src/java/org/apache/cassandra/triggers/CustomClassLoader.java#L81

      (3) https://github.com/apache/cassandra/blob/cassandra-4.1/src/java/org/apache/cassandra/io/util/FileUtils.java#L152

      Attachments

        Issue Links

          Activity

            People

              smiklosovic Stefan Miklosovic
              smiklosovic Stefan Miklosovic
              Stefan Miklosovic
              Brandon Williams
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 50m
                  1h 50m