Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/119' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Jan 23, 2018
2 parents 7fa51b3 + 3bbadbd commit 08eef2b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/mariadb/jdbc/MariaDbBlob.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public MariaDbBlob() {
*/
public MariaDbBlob(byte[] bytes) {
if (bytes == null) {
throw new AssertionError("byte array is null");
throw new NullPointerException("byte array is null");
}
data = bytes;
offset = 0;
Expand All @@ -99,7 +99,7 @@ public MariaDbBlob(byte[] bytes) {
*/
public MariaDbBlob(byte[] bytes, int offset, int length) {
if (bytes == null) {
throw new AssertionError("byte array is null");
throw new NullPointerException("byte array is null");
}
data = bytes;
this.offset = offset;
Expand Down
19 changes: 8 additions & 11 deletions src/main/java/org/mariadb/jdbc/MariaDbClob.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper;

import java.io.*;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.StandardCharsets;
import java.sql.Clob;
import java.sql.NClob;
Expand Down Expand Up @@ -97,11 +98,7 @@ public MariaDbClob() {
* @return string value of blob content.
*/
public String toString() {
try {
return new String(data, offset, length, StandardCharsets.UTF_8);
} catch (Exception e) {
throw new AssertionError(e);
}
return new String(data, offset, length, StandardCharsets.UTF_8);
}

/**
Expand Down Expand Up @@ -192,15 +189,15 @@ private int utf8Position(int charPosition) {
if (byteValue < 0x80) {
pos += 1;
} else if (byteValue < 0xC2) {
throw new AssertionError("invalid UTF8");
throw new UncheckedIOException("invalid UTF8",new CharacterCodingException());
} else if (byteValue < 0xE0) {
pos += 2;
} else if (byteValue < 0xF0) {
pos += 3;
} else if (byteValue < 0xF8) {
pos += 4;
} else {
throw new AssertionError("invalid UTF8");
throw new UncheckedIOException("invalid UTF8",new CharacterCodingException());
}
}
return pos;
Expand Down Expand Up @@ -239,15 +236,15 @@ public long length() {
if (byteValue < 0x80) {
i += 1;
} else if (byteValue < 0xC2) {
throw new AssertionError("invalid UTF8");
throw new UncheckedIOException("invalid UTF8",new CharacterCodingException());
} else if (byteValue < 0xE0) {
i += 2;
} else if (byteValue < 0xF0) {
i += 3;
} else if (byteValue < 0xF8) {
i += 4;
} else {
throw new AssertionError("invalid UTF8");
throw new UncheckedIOException("invalid UTF8",new CharacterCodingException());
}
len++;
}
Expand All @@ -262,15 +259,15 @@ public void truncate(final long len) throws SQLException {
if (byteValue < 0x80) {
pos += 1;
} else if (byteValue < 0xC2) {
throw new AssertionError("invalid UTF8");
throw new UncheckedIOException("invalid UTF8",new CharacterCodingException());
} else if (byteValue < 0xE0) {
pos += 2;
} else if (byteValue < 0xF0) {
pos += 3;
} else if (byteValue < 0xF8) {
pos += 4;
} else {
throw new AssertionError("invalid UTF8");
throw new UncheckedIOException("invalid UTF8",new CharacterCodingException());
}
}
length = pos - offset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ private static int getImportedKeyAction(String actionKey) {
return DatabaseMetaData.importedKeyRestrict;

default:
throw new AssertionError("should not happen");
throw new IllegalArgumentException("Illegal key action '" + actionKey + "' specified.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void authenticate(final PacketOutputStream writer, final String serverPri
}
jaasConfFile.deleteOnExit();
} catch (final IOException ex) {
throw new IOError(ex);
throw new UncheckedIOException(ex);
}

System.setProperty("java.security.auth.login.config", jaasConfFile.getCanonicalPath());
Expand Down

0 comments on commit 08eef2b

Please sign in to comment.