LuciferYang commented on code in PR #52845:
URL: https://github.com/apache/spark/pull/52845#discussion_r2485324194


##########
common/utils/src/main/scala/org/apache/spark/ErrorClassesJSONReader.scala:
##########
@@ -152,7 +153,9 @@ private object ErrorClassesJsonReader {
     .addModule(DefaultScalaModule)
     .build()
   private def readAsMap(url: URL): Map[String, ErrorInfo] = {
-    val map = mapper.readValue(url, new TypeReference[Map[String, 
ErrorInfo]]() {})
+    val map = SparkErrorUtils.tryWithResource(url.openStream()) { inputStream 
=>
+      mapper.readValue(inputStream, new TypeReference[Map[String, 
ErrorInfo]]() {})

Review Comment:
   
https://github.com/FasterXML/jackson-databind/blob/4260f88180e5e45f3be1a290114e55c042bb2213/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java#L3994-L4000
   
   
   What's being called here is _readMapAndClose, so we don't need to manually 
close the InputStream. Let me clean them up. Thank you.



##########
common/utils/src/main/scala/org/apache/spark/ErrorClassesJSONReader.scala:
##########
@@ -152,7 +153,9 @@ private object ErrorClassesJsonReader {
     .addModule(DefaultScalaModule)
     .build()
   private def readAsMap(url: URL): Map[String, ErrorInfo] = {
-    val map = mapper.readValue(url, new TypeReference[Map[String, 
ErrorInfo]]() {})
+    val map = SparkErrorUtils.tryWithResource(url.openStream()) { inputStream 
=>
+      mapper.readValue(inputStream, new TypeReference[Map[String, 
ErrorInfo]]() {})

Review Comment:
   
https://github.com/FasterXML/jackson-databind/blob/4260f88180e5e45f3be1a290114e55c042bb2213/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java#L3994-L4000
   
   
   What's being called here is _readMapAndClose, so we don't need to manually 
close the InputStream. Let me clean them up. Thank you @dongjoon-hyun 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to