Skip to content

Commit 93c1183

Browse files
committed
remove redundant check of responseCode
The responseCode is unset in the getInputStream method as the initiation of the value is removed from the connect method.
1 parent 9603f7d commit 93c1183

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

sbt-gcs-plugin/src/main/scala/org/latestbit/sbt/gcs/artifactregistry/GcsArtifactRegistryUrlConnection.scala

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ import com.google.api.client.http.{
2424
}
2525
import sbt.Logger
2626

27-
import java.io.{ ByteArrayOutputStream, InputStream, OutputStream }
28-
import java.net.{ HttpURLConnection, URL }
29-
import scala.util.Try
27+
import java.io.{ByteArrayOutputStream, InputStream, OutputStream}
28+
import java.net.{HttpURLConnection, URL}
3029
import scala.jdk.CollectionConverters.*
3130
import scala.util.control.NonFatal
3231

@@ -56,25 +55,21 @@ class GcsArtifactRegistryUrlConnection( googleHttpRequestFactory: HttpRequestFac
5655
if (!connected) {
5756
connect()
5857
}
59-
if (responseCode < 400) {
60-
try {
61-
logger.debug( s"Receiving an artifact from url: ${url}." )
62-
val httpRequest = googleHttpRequestFactory.buildGetRequest( genericUrl )
58+
try {
59+
logger.debug( s"Receiving an artifact from url: ${url}." )
60+
val httpRequest = googleHttpRequestFactory.buildGetRequest( genericUrl )
6361

64-
val httpResponse = appendHeadersBeforeConnect( httpRequest ).execute()
62+
val httpResponse = appendHeadersBeforeConnect( httpRequest ).execute()
6563

66-
val inputStream = httpResponse.getContent
67-
inputStreamIsReady = Some( inputStream )
68-
inputStream
69-
} catch {
70-
case ex: HttpResponseException => {
71-
responseCode = ex.getStatusCode
72-
responseMessage = ex.getStatusMessage
73-
null
74-
}
64+
val inputStream = httpResponse.getContent
65+
inputStreamIsReady = Some( inputStream )
66+
inputStream
67+
} catch {
68+
case ex: HttpResponseException => {
69+
responseCode = ex.getStatusCode
70+
responseMessage = ex.getStatusMessage
71+
null
7572
}
76-
} else {
77-
null
7873
}
7974
}
8075
}

0 commit comments

Comments
 (0)