TargetSource.getTarget() is nullable again (for compatibility with MethodInvocation.getThis)
Issue: SPR-15651
This commit is contained in:
parent
47ec966757
commit
738160538e
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2015 the original author or authors.
|
* Copyright 2002-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -97,7 +97,7 @@ public abstract class AbstractPrototypeBasedTargetSource extends AbstractBeanFac
|
||||||
|
|
||||||
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
|
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
|
||||||
throw new NotSerializableException("A prototype-based TargetSource itself is not deserializable - " +
|
throw new NotSerializableException("A prototype-based TargetSource itself is not deserializable - " +
|
||||||
"just a disconnected SingletonTargetSource is");
|
"just a disconnected SingletonTargetSource or EmptyTargetSource is");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -113,13 +113,15 @@ public abstract class AbstractPrototypeBasedTargetSource extends AbstractBeanFac
|
||||||
logger.debug("Disconnecting TargetSource [" + this + "]");
|
logger.debug("Disconnecting TargetSource [" + this + "]");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// Create disconnected SingletonTargetSource.
|
// Create disconnected SingletonTargetSource/EmptyTargetSource.
|
||||||
return new SingletonTargetSource(getTarget());
|
Object target = getTarget();
|
||||||
|
return (target != null ? new SingletonTargetSource(target) :
|
||||||
|
EmptyTargetSource.forClass(getTargetClass()));
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
logger.error("Cannot get target for disconnecting TargetSource [" + this + "]", ex);
|
String msg = "Cannot get target for disconnecting TargetSource [" + this + "]";
|
||||||
throw new NotSerializableException(
|
logger.error(msg, ex);
|
||||||
"Cannot get target for disconnecting TargetSource [" + this + "]: " + ex);
|
throw new NotSerializableException(msg + ": " + ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue