Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In JsonParser.java use try-with-resource for JsonReader jsonReader = Json.createReader(new StringReader(jsonString)); in method remapGeographicCoverage(...) #9314

Closed
rtreacy opened this issue Jan 23, 2023 · 3 comments · Fixed by #9923
Labels
D: SonarQubeCleanup Issues related to cleanup based on Sonar Cube tool Size: 3 A percentage of a sprint. 2.1 hours.
Milestone

Comments

@rtreacy
Copy link
Contributor

rtreacy commented Jan 23, 2023

No description provided.

@rtreacy rtreacy converted this from a draft issue Jan 23, 2023
@rtreacy rtreacy moved this to SonarQube cleanup (Gustavo) in IQSS Dataverse Project Jan 23, 2023
@mreekie mreekie added the Size: Queued PM has called this issue out specifically for sizing label Jan 26, 2023
@mreekie mreekie added the D: SonarQubeCleanup Issues related to cleanup based on Sonar Cube tool label Feb 28, 2023
@cmbz cmbz moved this from SonarQube cleanup (Gustavo) to SPRINT- NEEDS SIZING in IQSS Dataverse Project Apr 19, 2023
@mreekie mreekie added Size: 3 A percentage of a sprint. 2.1 hours. and removed Size: Queued PM has called this issue out specifically for sizing labels May 2, 2023
@mreekie
Copy link

mreekie commented May 2, 2023

Sizing:

  • If this is a single file, then this should be a 3.
  • simple fix.

@mreekie mreekie moved this from SPRINT- NEEDS SIZING to SPRINT READY in IQSS Dataverse Project May 2, 2023
@qqmyers
Copy link
Member

qqmyers commented May 2, 2023

Using the JsonUtil.getJsonObject() or getJsonArray methods would be better than just adding a try with resources.

@cmbz cmbz moved this from SPRINT READY to Clear of the Backlog in IQSS Dataverse Project Sep 13, 2023
@pdurbin
Copy link
Member

pdurbin commented Sep 15, 2023

@bencomp are you interested in creating a PR to fix this issue? As of 4e1bc5b this is the line in question:

diff --git a/src/main/java/edu/harvard/iq/dataverse/util/json/JsonParser.java b/src/main/java/edu/harvard/iq/dataverse/util/json/JsonParser.java
index febb785cd9..8f3ffd2671 100644
--- a/src/main/java/edu/harvard/iq/dataverse/util/json/JsonParser.java
+++ b/src/main/java/edu/harvard/iq/dataverse/util/json/JsonParser.java
@@ -682,7 +682,7 @@ public class JsonParser {
         // convert DTO to datasetField so we can back valid values.
         Gson gson = new Gson();
         String jsonString = gson.toJson(geoCoverageDTO);
-        JsonReader jsonReader = Json.createReader(new StringReader(jsonString));
+        JsonReader jsonReader = Json.createReader(new StringReader(jsonString)); // HERE
         JsonObject obj = jsonReader.readObject();
         DatasetField geoCoverageField = parseField(obj);

We have a snapshot from Sonarcloud from a couple weeks ago that also shows it: https://sonarcloud.io/code?id=IQSS_dataverse&selected=IQSS_dataverse%3Asrc%2Fmain%2Fjava%2Fedu%2Fharvard%2Fiq%2Fdataverse%2Futil%2Fjson%2FJsonParser.java&line=685

Screen Shot 2023-09-15 at 10 44 47 AM

Screen Shot 2023-09-15 at 10 44 01 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D: SonarQubeCleanup Issues related to cleanup based on Sonar Cube tool Size: 3 A percentage of a sprint. 2.1 hours.
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

4 participants