Skip to content

Commit

Permalink
Tentative fix for deadlock in lastModifiedImpl
Browse files Browse the repository at this point in the history
It really shouldn't deadlock, but we have a thread dump from a customer showing that it might. Could this be explained by the break with label? This is rarely used this way and could exhibit a bug somewhere (compiler, VM?). That seems unlikely but is worth trying.
  • Loading branch information
ebruchez committed Dec 20, 2012
1 parent 079dd4d commit f054f8e
Showing 1 changed file with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,33 +107,33 @@ protected long lastModifiedImpl(final String key, boolean doNotThrowResourceNotF
*
*/
final long ret;
done : try {
try {
final java.net.URLConnection uc = getConnection( key, doNotThrowResourceNotFound);
if (uc == null) {
ret = -1;
break done;
}
if ( uc instanceof java.net.JarURLConnection ) {
final JarEntry je
= ( ( java.net.JarURLConnection )uc ).getJarEntry();
ret = je.getTime();
break done;
}
final java.net.URL url = uc.getURL();
final String prot = url.getProtocol();
if ( "file".equalsIgnoreCase( prot ) ) {
final String fnam = url.getPath();
final java.io.File f = new java.io.File( fnam );
if ( f.exists() ) {
ret = f.lastModified();
} else {
final String fnamDec = java.net.URLDecoder.decode( fnam, "utf-8" );
final java.io.File fdec = new java.io.File( fnamDec );
ret = f.lastModified();
}
} else {
final long l = NetUtils.getLastModified( uc );
ret = l == 0 ? 1 : l;
if ( uc instanceof java.net.JarURLConnection ) {
final JarEntry je
= ( ( java.net.JarURLConnection )uc ).getJarEntry();
ret = je.getTime();
} else {
final java.net.URL url = uc.getURL();
final String prot = url.getProtocol();
if ( "file".equalsIgnoreCase( prot ) ) {
final String fnam = url.getPath();
final java.io.File f = new java.io.File( fnam );
if ( f.exists() ) {
ret = f.lastModified();
} else {
final String fnamDec = java.net.URLDecoder.decode( fnam, "utf-8" );
final java.io.File fdec = new java.io.File( fnamDec );
ret = f.lastModified();
}
} else {
final long l = NetUtils.getLastModified( uc );
ret = l == 0 ? 1 : l;
}
}
}
} catch ( final java.io.IOException e ) {
throw new OXFException( e );
Expand Down

0 comments on commit f054f8e

Please sign in to comment.