Guest User

Untitled

a guest
Feb 25th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. import java.net.URI;
  2.  
  3. import com.marklogic.xcc.ContentSource;
  4. import com.marklogic.xcc.ContentSourceFactory;
  5. import com.marklogic.xcc.Session;
  6.  
  7. public class mve {
  8. public static void main(String[] args) throws Exception {
  9. if (args.length != 1) {
  10. System.err.println("usage: xcc://user:password@host:port/contentbase");
  11. return;
  12. }
  13.  
  14. System.out.println("Running minimal viable example of MarkLogic isAutoCommit/getUpdate bug...");
  15.  
  16. URI uri = new URI(args[0]);
  17. ContentSource contentSource = ContentSourceFactory.newContentSource(uri);
  18. Session updateSession = contentSource.newSession();
  19.  
  20. // comment out the following two lines to cause a NullPointerException to be thrown on getUpdate and isAutoCommit:
  21. updateSession.setAutoCommit(false);
  22. updateSession.setUpdate(Session.Update.TRUE);
  23.  
  24. System.out.println("is AutoCommit?");
  25. System.out.println(updateSession.isAutoCommit()); // if lines 21 and 22 are both commented out, this will cause NPE
  26.  
  27. System.out.println("getUpdate?");
  28. System.out.println(updateSession.getUpdate()); // if lines 21 and 22 are both commented out, this will cause NPE
  29. }
  30. }
Add Comment
Please, Sign In to add comment