Skip to content

Commit cb76db2

Browse files
committed
LDEV-6211 improve metadata exception logging, but lower to DEBUG
1 parent 2bd067d commit cb76db2

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

source/java/src/org/lucee/extension/image/Metadata.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,20 @@ public static void addExifInfoToStruct(final Resource res, Struct info, Log log)
9090
}
9191
}
9292
catch (Exception e) {
93-
if (log != null) log.log(Log.LEVEL_WARN, "imaging", "failed to read EXIF metadata from [" + res + "], metadata is ignored", e);
93+
if (log != null) log.log(Log.LEVEL_DEBUG, "imaging", "failed to read EXIF metadata from [" + res + "], metadata is ignored", e);
9494
}
9595
}
9696
// GPS
9797
try {
9898
gps(jpegMetadata, info);
9999
}
100100
catch (Exception e) {
101-
if (log != null) log.error("imaging", e);
101+
if (log != null) log.log(Log.LEVEL_DEBUG, "imaging", "failed to read GPS metadata from [" + res + "], metadata is ignored", e);
102102
}
103103
}
104104
}
105105
catch (Exception ex) {
106-
if (log != null) log.error("imaging", ex);
106+
if (log != null) log.log(Log.LEVEL_DEBUG, "imaging", "failed to read EXIF metadata from [" + res + "], metadata is ignored", ex);
107107
}
108108
finally {
109109
Util.closeEL(is);

tests/LDEV6211.cfc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
component extends="org.lucee.cfml.test.LuceeTestCase" labels="image" {
2+
3+
variables.imgDir = getDirectoryFromPath( getCurrentTemplatePath() ) & "images/";
4+
variables.testDir = getTempDirectory() & "ldev6211/";
5+
6+
function beforeAll(){
7+
if ( directoryExists( testDir ) ) directoryDelete( testDir, true );
8+
directoryCreate( testDir );
9+
10+
fileCopy( imgDir & "small-sample.webp", testDir & "sample.webp" );
11+
// file with a truly unknown extension to force the outer catch
12+
fileCopy( imgDir & "small-sample.webp", testDir & "mystery.xyz" );
13+
}
14+
15+
function run( testResults, testBox ){
16+
describe( "LDEV-6211 unsupported formats must not throw from imageInfo", function(){
17+
18+
it( title="imageInfo on a .webp file returns without throwing", body=function(){
19+
var info = imageInfo( testDir & "sample.webp" );
20+
expect( info.width ).toBeGT( 0 );
21+
expect( info.height ).toBeGT( 0 );
22+
});
23+
24+
it( title="imageInfo on a file with unknown extension returns without throwing", body=function(){
25+
var info = imageInfo( testDir & "mystery.xyz" );
26+
expect( info.width ).toBeGT( 0 );
27+
expect( info.height ).toBeGT( 0 );
28+
});
29+
30+
});
31+
}
32+
33+
}

0 commit comments

Comments
 (0)