diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java index 017e813d25d..f6d9a1073e7 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java @@ -85,7 +85,7 @@ public byte[] toBytes(Object object) { } byte[] b = PVarchar.INSTANCE.toBytes(object); if (b.length != ((String) object).length()) { - throw newIllegalDataException("CHAR types may only contain single byte characters (" + object + ")"); + throw newIllegalDataException("CHAR types may only contain single byte characters."); } return b; } @@ -97,7 +97,7 @@ public int toBytes(Object object, byte[] bytes, int offset) { } int len = PVarchar.INSTANCE.toBytes(object, bytes, offset); if (len != ((String) object).length()) { - throw newIllegalDataException("CHAR types may only contain single byte characters (" + object + ")"); + throw newIllegalDataException("CHAR types may only contain single byte characters."); } return len; } @@ -118,7 +118,7 @@ public Object toObject(byte[] bytes, int offset, int length, PDataType actualTyp // TODO: UTF-8 decoder that will invert as it decodes String s = Bytes.toString(bytes, offset, length); if (length != s.length()) { - throw newIllegalDataException("CHAR types may only contain single byte characters (" + s + ")"); + throw newIllegalDataException("CHAR types may only contain single byte characters."); } return s; } @@ -142,7 +142,7 @@ public void coerceBytes(ImmutableBytesWritable ptr, Object o, PDataType actualTy Integer actualMaxLength, Integer actualScale, SortOrder actualModifier, Integer desiredMaxLength, Integer desiredScale, SortOrder expectedModifier) { if (o != null && actualType.equals(PVarchar.INSTANCE) && ((String)o).length() != ptr.getLength()) { - throw newIllegalDataException("CHAR types may only contain single byte characters (" + o + ")"); + throw newIllegalDataException("CHAR types may only contain single byte characters."); } super.coerceBytes(ptr, o, actualType, actualMaxLength, actualScale, actualModifier, desiredMaxLength, desiredScale, expectedModifier); if (ptr.getLength() > 0 && desiredMaxLength != null && @@ -201,7 +201,7 @@ public int compareTo(Object lhs, Object rhs, PDataType rhsType) { @Override public Object toObject(String value) { if (StringUtil.hasMultiByteChars(value)) { - throw newIllegalDataException("CHAR types may only contain single byte characters (" + value + ")"); + throw newIllegalDataException("CHAR types may only contain single byte characters."); } return value; } diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java index ac32956c849..7a450a81629 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java @@ -631,6 +631,7 @@ public void testUpsertTypeMismatch() throws Exception { @Test public void testUpsertMultiByteIntoChar() throws Exception { + String value = "繰り返し曜日マスク"; try { // Select non agg column in aggregate query String query = "upsert into ATABLE VALUES (?, ?, ?)"; @@ -639,7 +640,7 @@ public void testUpsertMultiByteIntoChar() throws Exception { try { PreparedStatement statement = conn.prepareStatement(query); statement.setString(1, "00D300000000XHP"); - statement.setString(2, "繰り返し曜日マスク"); + statement.setString(2, value); statement.setInt(3, 1); statement.executeUpdate(); fail(); @@ -649,6 +650,7 @@ public void testUpsertMultiByteIntoChar() throws Exception { } catch (SQLException e) { assertTrue(e.getMessage(), e.getMessage().contains("ERROR 201 (22000): Illegal data.")); assertTrue(e.getMessage().contains("CHAR types may only contain single byte characters")); + assertFalse(e.getMessage().contains(value)); } }