77
88import org .jabref .logic .shared .exception .MscCodeLoadingException ;
99
10- import com .fasterxml .jackson .core .JsonParseException ;
11- import com .fasterxml .jackson .core .type .TypeReference ;
12- import com .fasterxml .jackson .databind .JsonMappingException ;
13- import com .fasterxml .jackson .databind .ObjectMapper ;
1410import com .google .common .collect .HashBiMap ;
1511import org .jspecify .annotations .NonNull ;
1612import org .slf4j .Logger ;
1713import org .slf4j .LoggerFactory ;
14+ import tools .jackson .core .exc .StreamReadException ;
15+ import tools .jackson .core .type .TypeReference ;
16+ import tools .jackson .databind .DatabindException ;
17+ import tools .jackson .databind .ObjectMapper ;
18+ import tools .jackson .databind .json .JsonMapper ;
1819
1920public class MscCodeUtils {
2021 private static final Logger LOGGER = LoggerFactory .getLogger (MscCodeUtils .class );
@@ -29,10 +30,10 @@ public class MscCodeUtils {
2930 @ NonNull
3031 public static Optional <HashBiMap <String , String >> loadMscCodesFromJson (URL resourceUrl ) throws MscCodeLoadingException {
3132
32- ObjectMapper mapper = new ObjectMapper ();
33+ ObjectMapper mapper = new JsonMapper ();
3334 try {
3435 Map <String , String > mapping =
35- mapper .readValue (resourceUrl , new TypeReference <>() {
36+ mapper .readValue (resourceUrl . openStream () , new TypeReference <>() {
3637 });
3738 HashBiMap <String , String > result = HashBiMap .create (mapping );
3839
@@ -41,7 +42,7 @@ public static Optional<HashBiMap<String, String>> loadMscCodesFromJson(URL resou
4142 }
4243
4344 return Optional .of (result );
44- } catch (JsonParseException | JsonMappingException e ) {
45+ } catch (StreamReadException | DatabindException e ) {
4546 LOGGER .error ("Error parsing MSC codes from JSON" , e );
4647 throw new MscCodeLoadingException ("Failed to parse MSC codes from JSON" , e );
4748 } catch (IOException e ) {
0 commit comments