Skip to content

Commit 5a78810

Browse files
committed
[912] Fix NullPointerException when Catalog name is an empty string
1 parent 3b80f9c commit 5a78810

File tree

2 files changed

+331
-42
lines changed

2 files changed

+331
-42
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/provider/service/ReactiveImprovedExtractionContextImpl.java

Lines changed: 328 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,26 @@
55
*/
66
package org.hibernate.reactive.provider.service;
77

8+
import java.sql.Array;
9+
import java.sql.Blob;
10+
import java.sql.CallableStatement;
11+
import java.sql.Clob;
812
import java.sql.Connection;
13+
import java.sql.DatabaseMetaData;
14+
import java.sql.NClob;
15+
import java.sql.PreparedStatement;
916
import java.sql.ResultSet;
17+
import java.sql.SQLClientInfoException;
1018
import java.sql.SQLException;
19+
import java.sql.SQLWarning;
20+
import java.sql.SQLXML;
21+
import java.sql.Savepoint;
22+
import java.sql.Statement;
23+
import java.sql.Struct;
24+
import java.util.Map;
25+
import java.util.Properties;
1126
import java.util.concurrent.CompletionStage;
27+
import java.util.concurrent.Executor;
1228

1329
import org.hibernate.boot.model.naming.Identifier;
1430
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
@@ -35,25 +51,7 @@ public ReactiveImprovedExtractionContextImpl(
3551
super(
3652
registry,
3753
registry.getService( JdbcEnvironment.class ),
38-
new DdlTransactionIsolator() {
39-
@Override
40-
public JdbcContext getJdbcContext() {
41-
return null;
42-
}
43-
44-
@Override
45-
public void prepare() {
46-
}
47-
48-
@Override
49-
public Connection getIsolatedConnection() {
50-
return null;
51-
}
52-
53-
@Override
54-
public void release() {
55-
}
56-
},
54+
NoopDdlTransactionIsolator.INSTANCE,
5755
defaultCatalog,
5856
defaultSchema,
5957
databaseObjectAccess
@@ -95,4 +93,315 @@ private ResultSet getQueryResultSet(
9593
.toCompletableFuture()
9694
.join();
9795
}
96+
97+
private static class NoopDdlTransactionIsolator implements DdlTransactionIsolator {
98+
static final NoopDdlTransactionIsolator INSTANCE = new NoopDdlTransactionIsolator();
99+
100+
private NoopDdlTransactionIsolator() {
101+
}
102+
103+
@Override
104+
public JdbcContext getJdbcContext() {
105+
return null;
106+
}
107+
108+
@Override
109+
public void prepare() {
110+
}
111+
112+
@Override
113+
public Connection getIsolatedConnection() {
114+
return NoopConnection.INSTANCE;
115+
}
116+
117+
@Override
118+
public void release() {
119+
}
120+
}
121+
122+
private static class NoopConnection implements Connection {
123+
124+
static final NoopConnection INSTANCE = new NoopConnection();
125+
126+
private NoopConnection() {
127+
}
128+
129+
@Override
130+
public Statement createStatement() throws SQLException {
131+
return null;
132+
}
133+
134+
@Override
135+
public PreparedStatement prepareStatement(String sql) throws SQLException {
136+
return null;
137+
}
138+
139+
@Override
140+
public CallableStatement prepareCall(String sql) throws SQLException {
141+
return null;
142+
}
143+
144+
@Override
145+
public String nativeSQL(String sql) throws SQLException {
146+
return null;
147+
}
148+
149+
@Override
150+
public void setAutoCommit(boolean autoCommit) throws SQLException {
151+
152+
}
153+
154+
@Override
155+
public boolean getAutoCommit() throws SQLException {
156+
return false;
157+
}
158+
159+
@Override
160+
public void commit() throws SQLException {
161+
162+
}
163+
164+
@Override
165+
public void rollback() throws SQLException {
166+
167+
}
168+
169+
@Override
170+
public void close() throws SQLException {
171+
172+
}
173+
174+
@Override
175+
public boolean isClosed() throws SQLException {
176+
return false;
177+
}
178+
179+
@Override
180+
public DatabaseMetaData getMetaData() throws SQLException {
181+
return null;
182+
}
183+
184+
@Override
185+
public void setReadOnly(boolean readOnly) throws SQLException {
186+
187+
}
188+
189+
@Override
190+
public boolean isReadOnly() throws SQLException {
191+
return false;
192+
}
193+
194+
@Override
195+
public void setCatalog(String catalog) throws SQLException {
196+
197+
}
198+
199+
@Override
200+
public String getCatalog() throws SQLException {
201+
return null;
202+
}
203+
204+
@Override
205+
public void setTransactionIsolation(int level) throws SQLException {
206+
207+
}
208+
209+
@Override
210+
public int getTransactionIsolation() throws SQLException {
211+
return 0;
212+
}
213+
214+
@Override
215+
public SQLWarning getWarnings() throws SQLException {
216+
return null;
217+
}
218+
219+
@Override
220+
public void clearWarnings() throws SQLException {
221+
222+
}
223+
224+
@Override
225+
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
226+
return null;
227+
}
228+
229+
@Override
230+
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
231+
throws SQLException {
232+
return null;
233+
}
234+
235+
@Override
236+
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
237+
throws SQLException {
238+
return null;
239+
}
240+
241+
@Override
242+
public Map<String, Class<?>> getTypeMap() throws SQLException {
243+
return null;
244+
}
245+
246+
@Override
247+
public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
248+
249+
}
250+
251+
@Override
252+
public void setHoldability(int holdability) throws SQLException {
253+
254+
}
255+
256+
@Override
257+
public int getHoldability() throws SQLException {
258+
return 0;
259+
}
260+
261+
@Override
262+
public Savepoint setSavepoint() throws SQLException {
263+
return null;
264+
}
265+
266+
@Override
267+
public Savepoint setSavepoint(String name) throws SQLException {
268+
return null;
269+
}
270+
271+
@Override
272+
public void rollback(Savepoint savepoint) throws SQLException {
273+
274+
}
275+
276+
@Override
277+
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
278+
279+
}
280+
281+
@Override
282+
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
283+
throws SQLException {
284+
return null;
285+
}
286+
287+
@Override
288+
public PreparedStatement prepareStatement(
289+
String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
290+
return null;
291+
}
292+
293+
@Override
294+
public CallableStatement prepareCall(
295+
String sql,
296+
int resultSetType,
297+
int resultSetConcurrency,
298+
int resultSetHoldability) throws SQLException {
299+
return null;
300+
}
301+
302+
@Override
303+
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
304+
return null;
305+
}
306+
307+
@Override
308+
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
309+
return null;
310+
}
311+
312+
@Override
313+
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
314+
return null;
315+
}
316+
317+
@Override
318+
public Clob createClob() throws SQLException {
319+
return null;
320+
}
321+
322+
@Override
323+
public Blob createBlob() throws SQLException {
324+
return null;
325+
}
326+
327+
@Override
328+
public NClob createNClob() throws SQLException {
329+
return null;
330+
}
331+
332+
@Override
333+
public SQLXML createSQLXML() throws SQLException {
334+
return null;
335+
}
336+
337+
@Override
338+
public boolean isValid(int timeout) throws SQLException {
339+
return false;
340+
}
341+
342+
@Override
343+
public void setClientInfo(String name, String value) throws SQLClientInfoException {
344+
345+
}
346+
347+
@Override
348+
public void setClientInfo(Properties properties) throws SQLClientInfoException {
349+
350+
}
351+
352+
@Override
353+
public String getClientInfo(String name) throws SQLException {
354+
return null;
355+
}
356+
357+
@Override
358+
public Properties getClientInfo() throws SQLException {
359+
return null;
360+
}
361+
362+
@Override
363+
public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
364+
return null;
365+
}
366+
367+
@Override
368+
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
369+
return null;
370+
}
371+
372+
@Override
373+
public void setSchema(String schema) throws SQLException {
374+
375+
}
376+
377+
@Override
378+
public String getSchema() throws SQLException {
379+
return null;
380+
}
381+
382+
@Override
383+
public void abort(Executor executor) throws SQLException {
384+
385+
}
386+
387+
@Override
388+
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
389+
390+
}
391+
392+
@Override
393+
public int getNetworkTimeout() throws SQLException {
394+
return 0;
395+
}
396+
397+
@Override
398+
public <T> T unwrap(Class<T> iface) throws SQLException {
399+
return null;
400+
}
401+
402+
@Override
403+
public boolean isWrapperFor(Class<?> iface) throws SQLException {
404+
return false;
405+
}
406+
}
98407
}

0 commit comments

Comments
 (0)