From 135513cf9b95edadf7ab52be8b05c2d83019f3cd Mon Sep 17 00:00:00 2001 From: Sylvain Lebresne Date: Wed, 2 Jul 2014 10:23:19 +0200 Subject: [PATCH 1/2] Fix compilation with java 6 (JAVA-7147 regression) --- .../org/apache/cassandra/locator/CloudstackSnitch.java | 3 +-- src/java/org/apache/cassandra/utils/ByteBufferUtil.java | 7 +++---- src/java/org/apache/cassandra/utils/FBUtilities.java | 3 +++ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/java/org/apache/cassandra/locator/CloudstackSnitch.java b/src/java/org/apache/cassandra/locator/CloudstackSnitch.java index 57c973baf8..eb671d7342 100644 --- a/src/java/org/apache/cassandra/locator/CloudstackSnitch.java +++ b/src/java/org/apache/cassandra/locator/CloudstackSnitch.java @@ -27,7 +27,6 @@ import java.net.HttpURLConnection; import java.net.InetAddress; import java.net.URL; import java.net.URI; -import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.regex.Pattern; import java.util.regex.Matcher; @@ -137,7 +136,7 @@ public class CloudstackSnitch extends AbstractNetworkTopologySnitch byte[] b = new byte[cl]; is = new DataInputStream(new BufferedInputStream(conn.getInputStream())); is.readFully(b); - return new String(b, StandardCharsets.UTF_8); + return new String(b, FBUtilities.UTF_8); } finally { diff --git a/src/java/org/apache/cassandra/utils/ByteBufferUtil.java b/src/java/org/apache/cassandra/utils/ByteBufferUtil.java index 86f3f02102..acc48854db 100644 --- a/src/java/org/apache/cassandra/utils/ByteBufferUtil.java +++ b/src/java/org/apache/cassandra/utils/ByteBufferUtil.java @@ -74,7 +74,6 @@ import org.apache.cassandra.io.util.FileUtils; */ public class ByteBufferUtil { - private static final Charset UTF_8 = Charset.forName("UTF-8"); public static final ByteBuffer EMPTY_BYTE_BUFFER = ByteBuffer.wrap(new byte[0]); public static int compareUnsigned(ByteBuffer o1, ByteBuffer o2) @@ -121,7 +120,7 @@ public class ByteBufferUtil */ public static String string(ByteBuffer buffer) throws CharacterCodingException { - return string(buffer, UTF_8); + return string(buffer, FBUtilities.UTF_8); } /** @@ -135,7 +134,7 @@ public class ByteBufferUtil */ public static String string(ByteBuffer buffer, int position, int length) throws CharacterCodingException { - return string(buffer, position, length, UTF_8); + return string(buffer, position, length, FBUtilities.UTF_8); } /** @@ -228,7 +227,7 @@ public class ByteBufferUtil */ public static ByteBuffer bytes(String s) { - return ByteBuffer.wrap(s.getBytes(UTF_8)); + return ByteBuffer.wrap(s.getBytes(FBUtilities.UTF_8)); } /** diff --git a/src/java/org/apache/cassandra/utils/FBUtilities.java b/src/java/org/apache/cassandra/utils/FBUtilities.java index 8cb6dae995..437b6a86b8 100644 --- a/src/java/org/apache/cassandra/utils/FBUtilities.java +++ b/src/java/org/apache/cassandra/utils/FBUtilities.java @@ -27,6 +27,7 @@ import java.net.SocketException; import java.net.URL; import java.net.UnknownHostException; import java.nio.ByteBuffer; +import java.nio.charset.Charset; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.*; @@ -63,6 +64,8 @@ import org.codehaus.jackson.map.ObjectMapper; public class FBUtilities { + public static final Charset UTF_8 = Charset.forName("UTF-8"); + private static final Logger logger = LoggerFactory.getLogger(FBUtilities.class); private static ObjectMapper jsonMapper = new ObjectMapper(new JsonFactory()); From 04250f2e5c2f0e2b5fcacdbbfb9c62e25dbcc440 Mon Sep 17 00:00:00 2001 From: Sylvain Lebresne Date: Wed, 2 Jul 2014 10:26:44 +0200 Subject: [PATCH 2/2] Changelog --- CHANGES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.txt b/CHANGES.txt index bc44f26094..1a79e8d149 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,6 @@ 1.2.18 * Support Thrift tables clustering columns on CqlPagingInputFormat (CASSANDRA-7445) + * Fix compilation with java 6 broke by CASSANDRA-7147 1.2.17 * cqlsh: Fix CompositeType columns in DESCRIBE TABLE output (CASSANDRA-7399)