Skip to content

Commit 55fec96

Browse files
committed
Response error resolve fix
1 parent 310576a commit 55fec96

File tree

1 file changed

+25
-20
lines changed
  • com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client

1 file changed

+25
-20
lines changed

com.dbeaver.jdbc.driver.libsql/src/main/java/com/dbeaver/jdbc/driver/libsql/client/LibSqlClient.java

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
/*
22
* DBeaver - Universal Database Manager
3-
* Copyright (C) 2010-2024 DBeaver Corp and others
3+
* Copyright (C) 2010-2025 DBeaver Corp
44
*
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
5+
* All Rights Reserved.
86
*
9-
* http://www.apache.org/licenses/LICENSE-2.0
10-
*
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
7+
* NOTICE: All information contained herein is, and remains
8+
* the property of DBeaver Corp and its suppliers, if any.
9+
* The intellectual and technical concepts contained
10+
* herein are proprietary to DBeaver Corp and its suppliers
11+
* and may be covered by U.S. and Foreign Patents,
12+
* patents in process, and are protected by trade secret or copyright law.
13+
* Dissemination of this information or reproduction of this material
14+
* is strictly forbidden unless prior written permission is obtained
15+
* from DBeaver Corp.
1616
*/
1717
package com.dbeaver.jdbc.driver.libsql.client;
1818

1919
import com.dbeaver.jdbc.driver.libsql.LibSqlConstants;
20-
import com.google.gson.Gson;
21-
import com.google.gson.GsonBuilder;
22-
import com.google.gson.Strictness;
23-
import com.google.gson.ToNumberPolicy;
20+
import com.google.gson.*;
2421
import com.google.gson.stream.JsonWriter;
2522
import org.jkiss.code.NotNull;
2623
import org.jkiss.code.Nullable;
2724
import org.jkiss.utils.CommonUtils;
2825

29-
import java.io.*;
26+
import java.io.IOException;
27+
import java.io.StringReader;
28+
import java.io.StringWriter;
29+
import java.io.Writer;
3030
import java.net.CookieManager;
3131
import java.net.HttpURLConnection;
3232
import java.net.URL;
@@ -113,14 +113,19 @@ public LibSqlExecutionResult[] executeBatch(
113113
);
114114
try {
115115
String responseBody = httpResponse.body();
116-
try (Reader isr = new StringReader(responseBody)) {
116+
try (StringReader isr = new StringReader(responseBody)) {
117117
Response[] response;
118118
if (responseBody.startsWith("[")) {
119119
response = gson.fromJson(isr, Response[].class);
120120
} else {
121-
response = new Response[] {
122-
gson.fromJson(isr, Response.class)
123-
};
121+
Response parsedResponse;
122+
try {
123+
parsedResponse = gson.fromJson(isr, Response.class);
124+
} catch (JsonSyntaxException e) {
125+
parsedResponse = new Response();
126+
parsedResponse.error = responseBody;
127+
}
128+
response = new Response[] { parsedResponse };
124129
}
125130
LibSqlExecutionResult[] resultSets = new LibSqlExecutionResult[response.length];
126131
for (int i = 0; i < response.length; i++) {

0 commit comments

Comments
 (0)