Skip to content

Commit

Permalink
[CONJ-972] possible java.lang.ClassCastException when executing prepa…
Browse files Browse the repository at this point in the history
…red statement
  • Loading branch information
rusher committed May 19, 2022
1 parent a9806b4 commit 62252ae
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/main/java/org/mariadb/jdbc/util/ClientParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public final class ClientParser implements PrepareResult {

private final String sql;
private final List<byte[]> queryParts;
private final int paramCount;
private static final Map<String, ClientParser> cache = new LinkedHashMap<>(512);

private ClientParser(String sql, List<byte[]> queryParts) {
this.sql = sql;
Expand All @@ -35,7 +32,6 @@ private ClientParser(String sql, List<byte[]> queryParts) {
* @return ClientPrepareResult
*/
public static ClientParser parameterParts(String queryString, boolean noBackslashEscapes) {
if (cache.containsKey(queryString)) return cache.get(queryString);

List<byte[]> partList = new ArrayList<>();
LexState state = LexState.Normal;
Expand Down Expand Up @@ -156,9 +152,7 @@ public static ClientParser parameterParts(String queryString, boolean noBackslas
.getBytes(StandardCharsets.UTF_8));
}

ClientParser clientParser = new ClientParser(queryString, partList);
if (queryString.length() < 16384) cache.put(queryString, clientParser);
return clientParser;
return new ClientParser(queryString, partList);
}

public String getSql() {
Expand Down

0 comments on commit 62252ae

Please sign in to comment.