This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push:
new 145a640 No need to initialize instance variable to its default value.
145a640 is described below
commit 145a64079d2ae08a774e54a12e043192c21b5ecc
Author: Gary Gregory <[email protected]>
AuthorDate: Sun Jan 3 18:37:29 2021 -0500
No need to initialize instance variable to its default value.
Inline local variable used only once.
Use this in ctor consistently.
Inline internal method.
---
.../commons/compress/utils/ServiceLoaderIterator.java | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git
a/src/main/java/org/apache/commons/compress/utils/ServiceLoaderIterator.java
b/src/main/java/org/apache/commons/compress/utils/ServiceLoaderIterator.java
index aeda857..2ad9135 100644
--- a/src/main/java/org/apache/commons/compress/utils/ServiceLoaderIterator.java
+++ b/src/main/java/org/apache/commons/compress/utils/ServiceLoaderIterator.java
@@ -44,12 +44,11 @@ public class ServiceLoaderIterator<E> implements
Iterator<E> {
public ServiceLoaderIterator(final Class<E> service, final ClassLoader
classLoader) {
this.service = service;
- final ServiceLoader<E> serviceLoader = ServiceLoader.load(service,
classLoader);
- serviceLoaderIterator = serviceLoader.iterator();
- nextServiceLoader = null;
+ this.serviceLoaderIterator = ServiceLoader.load(service,
classLoader).iterator();
}
- private boolean getNextServiceLoader() {
+ @Override
+ public boolean hasNext() {
while (nextServiceLoader == null) {
try {
if (!serviceLoaderIterator.hasNext()) {
@@ -69,13 +68,8 @@ public class ServiceLoaderIterator<E> implements Iterator<E>
{
}
@Override
- public boolean hasNext() {
- return getNextServiceLoader();
- }
-
- @Override
public E next() {
- if (!getNextServiceLoader()) {
+ if (!hasNext()) {
throw new NoSuchElementException("No more elements for service " +
service.getName());
}
final E tempNext = nextServiceLoader;