@@ -105,29 +105,30 @@ private void performTopicOperation(String topic, String token, String fid, Strin
105105 connection .setRequestProperty ("x-goog-firebase-installations-auth" , token );
106106 connection .setDoOutput (false );
107107
108+ int responseCode ;
108109 try {
109- int responseCode = connection .getResponseCode ();
110- if (responseCode >= 200 && responseCode < 300 ) {
111- // Success
112- if (isDebugLogEnabled ()) {
113- Log .d (TAG , "Topic " + operation + " for: " + topic + " succeeded." );
114- }
115- return ;
116- } else if (responseCode == 404 || responseCode == 403 ) {
117- if (isDebugLogEnabled ()) {
118- Log .d (TAG , "Topic " + operation + " failed: " + connection .getResponseMessage ());
119- }
120- throw new IOException ("Topic " + operation + " failed: " + connection .getResponseMessage ());
121- } else if (responseCode >= 500 ) {
122- throw new IOException (ERROR_INTERNAL_SERVER_ERROR );
123- } else {
124- throw new IOException ("Topic " + operation + " failed with status: " + responseCode );
125- }
110+ responseCode = connection .getResponseCode ();
126111 } catch (IOException e ) {
127112 throw new IOException (ERROR_SERVICE_NOT_AVAILABLE , e );
128113 } finally {
129114 connection .disconnect ();
130115 }
116+
117+ if (responseCode >= 200 && responseCode < 300 ) {
118+ // Success
119+ if (isDebugLogEnabled ()) {
120+ Log .d (TAG , "Topic " + operation + " for: " + topic + " succeeded." );
121+ }
122+ } else if (responseCode == 404 || responseCode == 403 ) {
123+ if (isDebugLogEnabled ()) {
124+ Log .d (TAG , "Topic " + operation + " failed: " + connection .getResponseMessage ());
125+ }
126+ throw new IOException ("Topic " + operation + " failed: " + connection .getResponseMessage ());
127+ } else if (responseCode >= 500 ) {
128+ throw new IOException (ERROR_INTERNAL_SERVER_ERROR );
129+ } else {
130+ throw new IOException ("Topic " + operation + " failed with status: " + responseCode );
131+ }
131132 }
132133
133134 @ VisibleForTesting
0 commit comments