Skip to content

Commit

Permalink
Log instead of throwing parsing manifests. (#5167)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjudd committed Jun 9, 2023
1 parent 14d8d56 commit 028f83c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ public List<GlideModule> parse() {
}
}
}
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Finished loading Glide modules");
}
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException("Unable to find metadata to parse GlideModules", e);
}
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Finished loading Glide modules");
if (Log.isLoggable(TAG, Log.ERROR)) {
Log.e(TAG, "Failed to parse glide modules", e);
}
}

return modules;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.bumptech.glide.module;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
Expand All @@ -21,7 +20,6 @@
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.function.ThrowingRunnable;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
Expand Down Expand Up @@ -125,20 +123,12 @@ public void parse_withNullMetadata_doesNotThrow() throws NameNotFoundException {
}

@Test
public void parse_withMissingName_throwsRuntimeException() throws NameNotFoundException {
public void parse_withMissingName_doesNotThrow() throws NameNotFoundException {
PackageManager pm = mock(PackageManager.class);
doThrow(new NameNotFoundException("name")).when(pm).getApplicationInfo(anyString(), anyInt());
when(context.getPackageManager()).thenReturn(pm);

assertThrows(
"Unable to find metadata to parse GlideModules",
RuntimeException.class,
new ThrowingRunnable() {
@Override
public void run() {
parser.parse();
}
});
parser.parse();
}

private void addModuleToManifest(Class<?> moduleClass) {
Expand Down

0 comments on commit 028f83c

Please sign in to comment.