Skip to content

Commit aebfaf7

Browse files
committed
Attached is a patch that prevents a NullPointerException in the JDBC
driver if the translations files have not been properly installed. (We carefully avoided installing the translations file in a controlled environment here specifically to test for such a bug. :-) See attached description for more details. William -- William Webber william@peopleweb.net.au
1 parent 7f171b5 commit aebfaf7

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/interfaces/jdbc/org/postgresql/util/PSQLException.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,21 @@ private void translate(String id,Object[] args)
6666
try {
6767
bundle = ResourceBundle.getBundle("org.postgresql.errors");
6868
} catch(MissingResourceException e) {
69+
// translation files have not been installed.
70+
message = id;
6971
}
7072
}
7173

74+
if (bundle != null) {
7275
// Now look up a localized message. If one is not found, then use
7376
// the supplied message instead.
74-
message = null;
75-
try {
76-
message = bundle.getString(id);
77-
} catch(MissingResourceException e) {
78-
message = id;
79-
}
77+
message = null;
78+
try {
79+
message = bundle.getString(id);
80+
} catch(MissingResourceException e) {
81+
message = id;
82+
}
83+
}
8084

8185
// Expand any arguments
8286
if(args!=null)

0 commit comments

Comments
 (0)