Skip to content

Commit

Permalink
Annotate getDataClass and getDataSource from DataFetcher as NonNull (#…
Browse files Browse the repository at this point in the history
…2203)

Returning null from those will trigger obscure crash in MultiClassKey, annotation helps preventing that.
  • Loading branch information
Tolriq authored and sjudd committed Aug 4, 2017
1 parent 00886e7 commit 7004e59
Show file tree
Hide file tree
Showing 23 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions integration/okhttp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies {
annotationProcessor project(':annotation:compiler')

compile "com.squareup.okhttp:okhttp:2.7.1"
compile "com.android.support:support-annotations:{$SUPPORT_V4_VERSION}"
}

android {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.integration.okhttp;

import android.support.annotation.NonNull;
import android.util.Log;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
Expand Down Expand Up @@ -89,11 +90,13 @@ public void cancel() {
// TODO: call cancel on the client when this method is called on a background thread. See #257
}

@NonNull
@Override
public Class<InputStream> getDataClass() {
return InputStream.class;
}

@NonNull
@Override
public DataSource getDataSource() {
return DataSource.REMOTE;
Expand Down
1 change: 1 addition & 0 deletions integration/okhttp3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies {
annotationProcessor project(':annotation:compiler')

compile "com.squareup.okhttp3:okhttp:${OK_HTTP_VERSION}"
compile "com.android.support:support-annotations:{$SUPPORT_V4_VERSION}"
}

android {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.integration.okhttp3;

import android.support.annotation.NonNull;
import android.util.Log;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
Expand Down Expand Up @@ -87,11 +88,13 @@ public void cancel() {
}
}

@NonNull
@Override
public Class<InputStream> getDataClass() {
return InputStream.class;
}

@NonNull
@Override
public DataSource getDataSource() {
return DataSource.REMOTE;
Expand Down
1 change: 1 addition & 0 deletions integration/volley/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apply plugin: 'com.android.library'
dependencies {
compile project(':library')
compile "com.android.volley:volley:${VOLLEY_VERSION}"
compile "com.android.support:support-annotations:{$SUPPORT_V4_VERSION}"
annotationProcessor project(':annotation:compiler')

testCompile project(":testutil")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.integration.volley;

import android.support.annotation.NonNull;
import android.util.Log;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
Expand Down Expand Up @@ -67,11 +68,13 @@ public void cancel() {
}
}

@NonNull
@Override
public Class<InputStream> getDataClass() {
return InputStream.class;
}

@NonNull
@Override
public DataSource getDataSource() {
return DataSource.REMOTE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bumptech.glide.load.data;

import android.content.res.AssetManager;
import android.support.annotation.NonNull;
import android.util.Log;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
Expand Down Expand Up @@ -54,6 +55,7 @@ public void cancel() {
// Do nothing.
}

@NonNull
@Override
public DataSource getDataSource() {
return DataSource.LOCAL;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.load.data;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
Expand Down Expand Up @@ -91,10 +92,12 @@ interface DataCallback<T> {
/**
* Returns the class of the data this fetcher will attempt to obtain.
*/
@NonNull
Class<T> getDataClass();

/**
* Returns the {@link com.bumptech.glide.load.DataSource} this fetcher will return data from.
*/
@NonNull
DataSource getDataSource();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.content.res.AssetManager;
import android.os.ParcelFileDescriptor;
import android.support.annotation.NonNull;

import java.io.IOException;

/**
Expand All @@ -23,6 +25,7 @@ protected void close(ParcelFileDescriptor data) throws IOException {
data.close();
}

@NonNull
@Override
public Class<ParcelFileDescriptor> getDataClass() {
return ParcelFileDescriptor.class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import android.content.res.AssetFileDescriptor;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.support.annotation.NonNull;

import java.io.FileNotFoundException;
import java.io.IOException;

Expand All @@ -30,6 +32,7 @@ protected void close(ParcelFileDescriptor data) throws IOException {
data.close();
}

@NonNull
@Override
public Class<ParcelFileDescriptor> getDataClass() {
return ParcelFileDescriptor.class;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.load.data;

import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.Log;
import com.bumptech.glide.Priority;
Expand Down Expand Up @@ -154,11 +155,13 @@ public void cancel() {
isCancelled = true;
}

@NonNull
@Override
public Class<InputStream> getDataClass() {
return InputStream.class;
}

@NonNull
@Override
public DataSource getDataSource() {
return DataSource.REMOTE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.ContentResolver;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.util.Log;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
Expand Down Expand Up @@ -64,6 +65,7 @@ public void cancel() {
// Do nothing.
}

@NonNull
@Override
public DataSource getDataSource() {
return DataSource.LOCAL;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.bumptech.glide.load.data;

import android.content.res.AssetManager;
import android.support.annotation.NonNull;

import java.io.IOException;
import java.io.InputStream;

Expand All @@ -22,6 +24,7 @@ protected void close(InputStream data) throws IOException {
data.close();
}

@NonNull
@Override
public Class<InputStream> getDataClass() {
return InputStream.class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import android.net.Uri;
import android.os.Build;
import android.provider.ContactsContract;
import android.support.annotation.NonNull;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -91,6 +93,7 @@ protected void close(InputStream data) throws IOException {
data.close();
}

@NonNull
@Override
public Class<InputStream> getDataClass() {
return InputStream.class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.util.Log;
import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
Expand Down Expand Up @@ -96,11 +97,13 @@ public void cancel() {
// Do nothing.
}

@NonNull
@Override
public Class<InputStream> getDataClass() {
return InputStream.class;
}

@NonNull
@Override
public DataSource getDataSource() {
return DataSource.LOCAL;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.bumptech.glide.load.model;

import android.support.annotation.NonNull;

import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.Options;
Expand Down Expand Up @@ -69,11 +71,13 @@ public void cancel() {
// Do nothing.
}

@NonNull
@Override
public Class<Data> getDataClass() {
return converter.getDataClass();
}

@NonNull
@Override
public DataSource getDataSource() {
return DataSource.LOCAL;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.load.model;

import android.support.annotation.NonNull;
import android.util.Log;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
Expand Down Expand Up @@ -78,11 +79,13 @@ public void cancel() {
// Do nothing.
}

@NonNull
@Override
public Class<ByteBuffer> getDataClass() {
return ByteBuffer.class;
}

@NonNull
@Override
public DataSource getDataSource() {
return DataSource.LOCAL;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.load.model;

import android.support.annotation.NonNull;
import android.util.Base64;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
Expand Down Expand Up @@ -90,11 +91,13 @@ public void cancel() {
// Do nothing.
}

@NonNull
@Override
public Class<Data> getDataClass() {
return reader.getDataClass();
}

@NonNull
@Override
public DataSource getDataSource() {
return DataSource.LOCAL;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bumptech.glide.load.model;

import android.os.ParcelFileDescriptor;
import android.support.annotation.NonNull;
import android.util.Log;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
Expand Down Expand Up @@ -89,11 +90,13 @@ public void cancel() {
// Do nothing.
}

@NonNull
@Override
public Class<Data> getDataClass() {
return opener.getDataClass();
}

@NonNull
@Override
public DataSource getDataSource() {
return DataSource.LOCAL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
Expand Down Expand Up @@ -81,11 +82,13 @@ public void cancel() {
// Do nothing.
}

@NonNull
@Override
public Class<File> getDataClass() {
return File.class;
}

@NonNull
@Override
public DataSource getDataSource() {
return DataSource.LOCAL;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumptech.glide.load.model;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.Pools.Pool;
import com.bumptech.glide.Priority;
Expand Down Expand Up @@ -113,11 +114,13 @@ public void cancel() {
}
}

@NonNull
@Override
public Class<Data> getDataClass() {
return fetchers.get(0).getDataClass();
}

@NonNull
@Override
public DataSource getDataSource() {
return fetchers.get(0).getDataSource();
Expand Down
Loading

0 comments on commit 7004e59

Please sign in to comment.