Skip to content

Commit eade6da

Browse files
committed
Perform stronger early validation upon exported objects.
1 parent f975fc0 commit eade6da

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/main/java/org/cojen/dirmi/core/Engine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public Object export(Object name, Object obj) throws IOException {
139139

140140
if (obj != null) {
141141
// Validate the remote object.
142-
RemoteExaminer.remoteType(obj);
142+
RemoteInfo.examine(RemoteExaminer.remoteType(obj));
143143
}
144144

145145
mMainLock.lock();

src/main/java/org/cojen/dirmi/core/RemoteExaminer.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,24 @@
2525
*/
2626
final class RemoteExaminer {
2727
/**
28-
* Returns the remote interface implemented by the given remote object.
28+
* Returns the remote interface implemented by the given remote object, but doesn't fully
29+
* validate it.
2930
*
3031
* @throws NullPointerException if object is null
31-
* @throws IllegalArgumentException if object is malformed
32+
* @throws IllegalArgumentException if more than one remote interface is defined, or if no
33+
* remote interface is implemented at all
3234
*/
3335
static Class<?> remoteType(Object obj) {
3436
return remoteTypeForClass(obj.getClass());
3537
}
3638

3739
/**
38-
* @throws IllegalArgumentException if object is null or malformed
40+
* Returns the remote interface implemented by the given class, but doesn't fully validate
41+
* it.
42+
*
43+
* @throws NullPointerException if clazz is null
44+
* @throws IllegalArgumentException if more than one remote interface is defined, or if no
45+
* remote interface is implemented at all
3946
*/
4047
static Class<?> remoteTypeForClass(Class<?> clazz) {
4148
// Only consider the one that implements Remote.

0 commit comments

Comments
 (0)