Skip to content

Commit cdfc33d

Browse files
committed
2464: Static fix
1 parent 77c5620 commit cdfc33d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/main/java/com/magento/idea/magento2uct/packages/SupportedVersion.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package com.magento.idea.magento2uct.packages;
77

88
import java.io.BufferedReader;
9+
import java.io.IOException;
910
import java.io.InputStreamReader;
1011
import java.net.HttpURLConnection;
1112
import java.net.URL;
@@ -19,6 +20,7 @@
1920
public enum SupportedVersion {
2021
;
2122
private final String version;
23+
private static final Integer SUCCESS_CODE = 200;
2224

2325
SupportedVersion(final String version) {
2426
this.version = version;
@@ -69,9 +71,9 @@ public static List<String> getSupportedVersions() {
6971
* from a predefined URL and parses it into a list of version strings.
7072
*
7173
* @return List[String] containing supported version strings
72-
* @throws Exception if an error occurs during HTTP connection or JSON parsing
74+
* @throws IOException if an error occurs during HTTP connection or JSON parsing
7375
*/
74-
public static List<String> fetchSupportedVersions() throws Exception { //NOPMD - suppressed SignatureDeclareThrowsException
76+
public static List<String> fetchSupportedVersions() throws IOException {
7577
final String url = "https://repo.packagist.org/p2/magento/community-edition.json";
7678
final List<String> versions = new ArrayList<>();
7779

@@ -82,8 +84,8 @@ public static List<String> fetchSupportedVersions() throws Exception { //NOPMD -
8284
connection.setRequestMethod("GET");
8385
connection.setRequestProperty("Accept", "application/json");
8486

85-
if (connection.getResponseCode() != 200) { //NOPMD - suppressed AvoidLiteralsInIfCondition
86-
throw new Exception( //NOPMD - suppressed AvoidThrowingRawExceptionTypes
87+
if (connection.getResponseCode() != SUCCESS_CODE) {
88+
throw new IOException(//NOPMD - suppressed AvoidThrowingRawExceptionTypes
8789
"Failed to fetch data, HTTP response code: " + connection.getResponseCode()
8890
);
8991
}
@@ -94,7 +96,7 @@ public static List<String> fetchSupportedVersions() throws Exception { //NOPMD -
9496
) {
9597
final StringBuilder response = new StringBuilder();
9698
String line;
97-
while ((line = reader.readLine()) != null) { //NOPMD - suppressed AssignmentInOperand
99+
while ((line = reader.readLine()) != null) {//NOPMD - suppressed AssignmentInOperand
98100
response.append(line);
99101
}
100102

0 commit comments

Comments
 (0)