@@ -220,7 +220,7 @@ Map<String, String> getConnectConfig()
220220 private static int detectPort () throws IOException
221221 {
222222 try (ServerSocket socket = new ServerSocket (0 )) {
223- while (!socket .isBound ()) {
223+ while (!socket .isBound ()) {
224224 Thread .sleep (50 );
225225 }
226226 return socket .getLocalPort ();
@@ -803,23 +803,19 @@ private static File prepareBinaries(PgBinaryResolver pgBinaryResolver, File over
803803 mkdirs (pgDir );
804804 workingDirectory .setWritable (true , false );
805805
806- final File unpackLockFile = new File (pgDir , LOCK_FILE_NAME );
807806 final File pgDirExists = new File (pgDir , ".exists" );
808807
809808 if (!isPgBinReady (pgDirExists )) {
809+ File unpackLockFile = new File (pgDir , LOCK_FILE_NAME );
810810 try (FileOutputStream lockStream = new FileOutputStream (unpackLockFile );
811811 FileLock unpackLock = lockStream .getChannel ().tryLock ()) {
812812 if (unpackLock != null ) {
813- try {
814- LOG .info ("Extracting Postgres..." );
815- try (ByteArrayInputStream bais = new ByteArrayInputStream (baos .toByteArray ())) {
816- extractTxz (bais , pgDir );
817- }
818- if (!pgDirExists .createNewFile ()) {
819- pgDirExists .setLastModified (System .currentTimeMillis ());
820- }
821- } catch (Exception e ) {
822- LOG .error ("while unpacking Postgres" , e );
813+ LOG .info ("Extracting Postgres..." );
814+ try (ByteArrayInputStream bais = new ByteArrayInputStream (baos .toByteArray ())) {
815+ extractTxz (bais , pgDir );
816+ }
817+ if (!pgDirExists .createNewFile ()) {
818+ pgDirExists .setLastModified (System .currentTimeMillis ());
823819 }
824820 } else {
825821 // the other guy is unpacking for us.
@@ -838,6 +834,7 @@ private static File prepareBinaries(PgBinaryResolver pgBinaryResolver, File over
838834 }
839835 }
840836 } catch (final IOException | NoSuchAlgorithmException e ) {
837+ LOG .error ("Got error while unpacking Postgres" , e );
841838 throw new ExceptionInInitializerError (e );
842839 } catch (final InterruptedException ie ) {
843840 Thread .currentThread ().interrupt ();
0 commit comments