|
9 | 9 |
|
10 | 10 | import org.postgresql.jdbc.PgConnection; |
11 | 11 | import org.postgresql.util.DriverInfo; |
12 | | -import org.postgresql.util.ExpressionProperties; |
13 | 12 | import org.postgresql.util.GT; |
14 | 13 | import org.postgresql.util.HostSpec; |
15 | | -import org.postgresql.util.LogWriterHandler; |
16 | 14 | import org.postgresql.util.PGPropertyPasswordParser; |
17 | 15 | import org.postgresql.util.PGPropertyServiceParser; |
18 | 16 | import org.postgresql.util.PGPropertyUtil; |
|
39 | 37 | import java.util.Properties; |
40 | 38 | import java.util.Set; |
41 | 39 | import java.util.concurrent.TimeUnit; |
42 | | -import java.util.logging.ConsoleHandler; |
43 | | -import java.util.logging.Formatter; |
44 | 40 | import java.util.logging.Level; |
45 | 41 | import java.util.logging.Logger; |
46 | | -import java.util.logging.SimpleFormatter; |
47 | | -import java.util.logging.StreamHandler; |
48 | 42 |
|
49 | 43 | /** |
50 | 44 | * <p>The Java SQL framework allows for multiple database drivers. Each driver should supply a class |
@@ -249,8 +243,6 @@ private Properties loadDefaultProperties() throws IOException { |
249 | 243 | return null; |
250 | 244 | } |
251 | 245 | try { |
252 | | - // Setup java.util.logging.Logger using connection properties. |
253 | | - setupLoggerFromProperties(props); |
254 | 246 |
|
255 | 247 | LOGGER.log(Level.FINE, "Connecting with URL: {0}", url); |
256 | 248 |
|
@@ -291,73 +283,13 @@ private Properties loadDefaultProperties() throws IOException { |
291 | 283 | } |
292 | 284 | } |
293 | 285 |
|
294 | | - // Used to check if the handler file is the same |
295 | | - private static @Nullable String loggerHandlerFile; |
296 | | - |
297 | 286 | /** |
298 | | - * <p>Setup java.util.logging.Logger using connection properties.</p> |
299 | | - * |
300 | | - * <p>See {@link PGProperty#LOGGER_FILE} and {@link PGProperty#LOGGER_FILE}</p> |
301 | | - * |
| 287 | + * this is an empty method left here for graalvm |
| 288 | + * we removed the ability to setup the logger from properties |
| 289 | + * due to a security issue |
302 | 290 | * @param props Connection Properties |
303 | 291 | */ |
304 | 292 | private void setupLoggerFromProperties(final Properties props) { |
305 | | - final String driverLogLevel = PGProperty.LOGGER_LEVEL.get(props); |
306 | | - if (driverLogLevel == null) { |
307 | | - return; // Don't mess with Logger if not set |
308 | | - } |
309 | | - if ("OFF".equalsIgnoreCase(driverLogLevel)) { |
310 | | - PARENT_LOGGER.setLevel(Level.OFF); |
311 | | - return; // Don't mess with Logger if set to OFF |
312 | | - } else if ("DEBUG".equalsIgnoreCase(driverLogLevel)) { |
313 | | - PARENT_LOGGER.setLevel(Level.FINE); |
314 | | - } else if ("TRACE".equalsIgnoreCase(driverLogLevel)) { |
315 | | - PARENT_LOGGER.setLevel(Level.FINEST); |
316 | | - } |
317 | | - |
318 | | - ExpressionProperties exprProps = new ExpressionProperties(props, System.getProperties()); |
319 | | - final String driverLogFile = PGProperty.LOGGER_FILE.get(exprProps); |
320 | | - if (driverLogFile != null && driverLogFile.equals(loggerHandlerFile)) { |
321 | | - return; // Same file output, do nothing. |
322 | | - } |
323 | | - |
324 | | - for (java.util.logging.Handler handlers : PARENT_LOGGER.getHandlers()) { |
325 | | - // Remove previously set Handlers |
326 | | - handlers.close(); |
327 | | - PARENT_LOGGER.removeHandler(handlers); |
328 | | - loggerHandlerFile = null; |
329 | | - } |
330 | | - |
331 | | - java.util.logging.Handler handler = null; |
332 | | - if (driverLogFile != null) { |
333 | | - try { |
334 | | - handler = new java.util.logging.FileHandler(driverLogFile); |
335 | | - loggerHandlerFile = driverLogFile; |
336 | | - } catch (Exception ex) { |
337 | | - System.err.println("Cannot enable FileHandler, fallback to ConsoleHandler."); |
338 | | - } |
339 | | - } |
340 | | - |
341 | | - Formatter formatter = new SimpleFormatter(); |
342 | | - |
343 | | - if ( handler == null ) { |
344 | | - if (DriverManager.getLogWriter() != null) { |
345 | | - handler = new LogWriterHandler(DriverManager.getLogWriter()); |
346 | | - } else if ( DriverManager.getLogStream() != null) { |
347 | | - handler = new StreamHandler(DriverManager.getLogStream(), formatter); |
348 | | - } else { |
349 | | - handler = new ConsoleHandler(); |
350 | | - } |
351 | | - } else { |
352 | | - handler.setFormatter(formatter); |
353 | | - } |
354 | | - |
355 | | - Level loggerLevel = PARENT_LOGGER.getLevel(); |
356 | | - if (loggerLevel != null) { |
357 | | - handler.setLevel(loggerLevel); |
358 | | - } |
359 | | - PARENT_LOGGER.setUseParentHandlers(false); |
360 | | - PARENT_LOGGER.addHandler(handler); |
361 | 293 | } |
362 | 294 |
|
363 | 295 | /** |
|
0 commit comments