Skip to content

Commit 30e52ca

Browse files
committed
Stop assigning ConversionUtils delegates
This logic is inherently unsound, because it pollutes static state. It changes the behavior of the ConversionUtils methods depending on whether a SciJava Context with a ConvertService has ever been instantiated, and depending on the available Converter plugins. With this logic removed, all tests now pass, and pass more consistently, wheras before, the ConversionUtilsTest would have all passing tests when run standalone, and failing test(s) when run as part of the suite. I'm aware that this change may break some things downstream. But because no unit tests exist here in scijava-common to catch those theoretical cases, we will just have to give it a try by making a release, and then address any issues arising afterward.
1 parent b483075 commit 30e52ca

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/main/java/org/scijava/convert/AbstractConvertService.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@
3636
import java.util.Set;
3737

3838
import org.scijava.plugin.AbstractHandlerService;
39-
import org.scijava.util.ConversionUtils;
4039

4140
/**
42-
* Abstract superclass for {@link ConvertService} implementations. Sets this
43-
* service as the active delegate service in {@link ConversionUtils}.
41+
* Abstract superclass for {@link ConvertService} implementations.
4442
*
4543
* @author Mark Hiner
4644
*/
47-
public abstract class AbstractConvertService extends AbstractHandlerService<ConversionRequest, Converter<?, ?>>
48-
implements ConvertService {
45+
public abstract class AbstractConvertService //
46+
extends AbstractHandlerService<ConversionRequest, Converter<?, ?>> //
47+
implements ConvertService
48+
{
4949

5050
// -- ConversionService methods --
5151
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -159,13 +159,6 @@ public Collection<Class<?>> getCompatibleOutputClasses(final Class<?> source) {
159159
return compatibleClasses;
160160
}
161161

162-
// -- Service methods --
163-
164-
@Override
165-
public void initialize() {
166-
ConversionUtils.setDelegateService(this, getPriority());
167-
}
168-
169162
// -- Helper methods --
170163

171164
/**

0 commit comments

Comments
 (0)