5
5
import stroom .util .json .JsonUtil ;
6
6
import stroom .util .logging .LambdaLogger ;
7
7
import stroom .util .logging .LambdaLoggerFactory ;
8
+ import stroom .util .logging .LogUtil ;
8
9
import stroom .util .shared .NullSafe ;
9
10
10
- import com .fasterxml .jackson .databind .ObjectMapper ;
11
+ import com .fasterxml .jackson .databind .DeserializationFeature ;
12
+ import com .fasterxml .jackson .databind .ObjectReader ;
11
13
import jakarta .inject .Inject ;
12
14
import jakarta .inject .Provider ;
13
15
import jakarta .inject .Singleton ;
@@ -102,18 +104,19 @@ private void processAllFiles() {
102
104
}
103
105
});
104
106
LOGGER .info ("Completed reading {} data feed key files in {}" , counter , dirToWatch );
105
- } catch (IOException e ) {
106
- LOGGER .error ("Error reading contents of " + dirToWatch , e );
107
+ } catch (Exception e ) {
108
+ LOGGER .error ("Error reading contents of directory '{}': {}" , dirToWatch , LogUtil . exceptionMessage ( e ) );
107
109
}
108
110
}
109
111
110
112
private void processFile (final Path path ) {
111
113
if (path != null && Files .isRegularFile (path )) {
112
114
LOGGER .info ("Reading datafeed key file {}" , path .toAbsolutePath ().normalize ());
113
- final ObjectMapper mapper = JsonUtil .getMapper ();
115
+ final ObjectReader reader = JsonUtil .getMapper ().reader ()
116
+ .with (DeserializationFeature .FAIL_ON_UNKNOWN_PROPERTIES );
114
117
try (InputStream fileStream = new FileInputStream (path .toFile ())) {
115
118
try {
116
- final HashedDataFeedKeys hashedDataFeedKeys = mapper .readValue (fileStream ,
119
+ final HashedDataFeedKeys hashedDataFeedKeys = reader .readValue (fileStream ,
117
120
HashedDataFeedKeys .class );
118
121
if (hashedDataFeedKeys != null && NullSafe .hasItems (hashedDataFeedKeys .getDataFeedKeys ())) {
119
122
final int addedCount = dataFeedKeyServiceProvider .get ().addDataFeedKeys (hashedDataFeedKeys ,
@@ -125,11 +128,12 @@ private void processFile(final Path path) {
125
128
LOGGER .info ("No datafeed keys found in {}" , path .toAbsolutePath ().normalize ());
126
129
}
127
130
} catch (IOException e ) {
128
- LOGGER .error ("Error parsing file {}: {}" , path , e .getMessage (), e );
129
- throw new RuntimeException ( e );
131
+ LOGGER .debug ("Error parsing file {}: {}" , path , e .getMessage (), e );
132
+ LOGGER . error ( "Error parsing file {}: {} (enable DEBUG for stacktrace)" , path , e . getMessage () );
130
133
}
131
134
} catch (IOException e ) {
132
- LOGGER .error ("Error reading file {}: {}" , path , e .getMessage (), e );
135
+ LOGGER .debug ("Error reading file {}: {}" , path , e .getMessage (), e );
136
+ LOGGER .error ("Error reading file {}: {} (enable DEBUG for stacktrace)" , path , e .getMessage ());
133
137
}
134
138
}
135
139
}
0 commit comments