Skip to content

Commit 8e919ed

Browse files
Merge pull request #232 from desperateCoder/231-void-return-type
#231 fix void return type
2 parents 815ec85 + e19aae1 commit 8e919ed

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main/java/com/nextcloud/android/sso/api/NextcloudAPI.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.lang.annotation.Documented;
3434
import java.lang.annotation.Retention;
3535
import java.lang.annotation.Target;
36+
import java.lang.reflect.Constructor;
3637
import java.lang.reflect.Type;
3738

3839
import io.reactivex.Observable;
@@ -45,6 +46,18 @@ public class NextcloudAPI {
4546

4647
private static final String TAG = NextcloudAPI.class.getCanonicalName();
4748

49+
private static final Void NOTHING = getVoidInstance();
50+
51+
private static Void getVoidInstance() {
52+
Constructor<Void> constructor = (Constructor<Void>) Void.class.getDeclaredConstructors()[0];
53+
constructor.setAccessible(true);
54+
try {
55+
return constructor.newInstance();
56+
} catch (Exception e) {
57+
throw new IllegalStateException("Should never happen, but did: unable to instantiate Void");
58+
}
59+
}
60+
4861
private NetworkRequest networkRequest;
4962
private Gson gson;
5063

@@ -125,6 +138,8 @@ private <T> T convertStreamToTargetEntity(InputStream inputStream, Type targetEn
125138
Log.d(TAG, result.toString());
126139
}
127140
*/
141+
} else {
142+
result = (T) NOTHING;
128143
}
129144
}
130145
return result;

0 commit comments

Comments
 (0)