container/src/main/java/com/streamsets/datacollector/runner/StageRuntime.java
@Override
  public final BatchContext startBatch() {
    return (BatchContext) AccessController.doPrivileged(new PrivilegedAction() {
      public Object run() {
        try {
          Thread.currentThread().setContextClassLoader(mainClassLoader);
          return pushSourceContextDelegate.startBatch();
        } finally {
          Thread.currentThread().setContextClassLoader(getDefinition().getStageClassLoader());
        }
      }
    });
  }
@Override
  public final BatchContext startBatch() {
    return (BatchContext) AccessController.doPrivileged(new PrivilegedAction() {
      public Object run() {
        try {
          Thread.currentThread().setContextClassLoader(mainClassLoader);
          return pushSourceContextDelegate.startBatch();
        } finally {
          Thread.currentThread().setContextClassLoader(getDefinition().getStageClassLoader());
        }
      }
    });
  }
For all PushSource callbacks we have to make sure that we get back to a security context
of SDC container module, otherwise we won't be able to update state files with new offsets
and other stuff.