Skip to content

Commit

Permalink
Added todo comment and improved logic for raising an exception in Str…
Browse files Browse the repository at this point in the history
…eamUtils
  • Loading branch information
Aklakan committed May 8, 2024
1 parent 79d5a04 commit c4a1cf4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public boolean test(Object raw) {
converter.convert(casted);
result = true;
} catch(Exception e) {
// TODO We want to forward some exceptions such as UnsupportedPolymorphismException - use a predicate to decide whether to raise an exception?
result = false;
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.AbstractMap.SimpleEntry;
import java.util.Map.Entry;
import java.util.concurrent.Callable;
Expand Down Expand Up @@ -229,13 +230,18 @@ protected T computeNext() {
}

if (enumerable == null) {
try {
if (resource == null) {
if (resource == null) {
try {
resource = resourceSupplier.call();
} catch (Exception e) {
throw new RuntimeException(e);
}
Objects.requireNonNull(resource, "Resource supplier was expected to supply a resource but returned null.");
try {
enumerable = toEnumerable.apply(resource);
} catch (Exception e) {
throw new RuntimeException(e);
}
enumerable = toEnumerable.apply(resource);
} catch (Exception e) {
throw new RuntimeException(e);
}
}

Expand Down

0 comments on commit c4a1cf4

Please sign in to comment.