Prevent mutations to AdaptorContext after Adaptor.init()
This limitation has been the intention for a little while now, but many
cases were overlooked.
diff --git a/src/com/google/enterprise/adaptor/GsaCommunicationHandler.java b/src/com/google/enterprise/adaptor/GsaCommunicationHandler.java
index bfc11db..34b95db 100644
--- a/src/com/google/enterprise/adaptor/GsaCommunicationHandler.java
+++ b/src/com/google/enterprise/adaptor/GsaCommunicationHandler.java
@@ -868,11 +868,17 @@
@Override
public void addStatusSource(StatusSource source) {
+ if (afterInit) {
+ throw new IllegalStateException("After init()");
+ }
dashboard.addStatusSource(source);
}
@Override
public void setGetDocIdsFullErrorHandler(ExceptionHandler handler) {
+ if (afterInit) {
+ throw new IllegalStateException("After init()");
+ }
((PushRunnable) docIdFullPusher.getRunnable())
.setGetDocIdsErrorHandler(handler);
}
@@ -886,6 +892,9 @@
@Override
public void setGetDocIdsIncrementalErrorHandler(
ExceptionHandler handler) {
+ if (afterInit) {
+ throw new IllegalStateException("After init()");
+ }
((PushRunnable) docIdFullPusher.getRunnable())
.setGetDocIdsErrorHandler(handler);
}
@@ -903,6 +912,9 @@
@Override
public HttpContext createHttpContext(String path, HttpHandler handler) {
+ if (afterInit) {
+ throw new IllegalStateException("After init()");
+ }
return addFilters(scope.createContext(path, handler));
}