[Demonstration 1]

[Buggy Method]
public void open() {
    Class.forName("com.mysql.jdbc.Driver");
    conn = DriverManager.getConnection("jdbc:mysql://cslvm74.csc.calpoly.edu/cjacob07", "cjacob07", "Ma94ne07k");
}

[Buggy Hunk]
public void open() {

[Patch]
public void open() throws Exception {

[Demonstration 2]

[Buggy Method]
@Test
public void updatePropertyToNodeInTransactionAndRollbackTest() {
    // given
    Session session = sessionPool.createSession();
    session.setTransactionManager(transactionManager);
    TransactionalGraphService transactionalGraphService = new TransactionalGraphService();
    Transaction tran1 = session.beginTransaction();
    transactionalGraphService.context(tran1).createNode(new Label("Person"), new Properties().add("name", "Adam", STRING));
    transactionalGraphService.context(tran1).commit();
    assertThat(transactionalGraphService.getPersistentNodeById(1).isPresent()).isTrue();
    //when
    Transaction tran2 = session.beginTransaction();
    transactionalGraphService.context(tran2).setProperty(1, new Property("name", STRING, "Bob"));
    Node readedNode = transactionalGraphService.context(tran2).getNodeById(1).get();
    assertThat(readedNode.getProperty("name").get()).isEqualTo(new Property("name", STRING, "Bob"));
    transactionalGraphService.context(tran2).rollback();
    // then
    assertThat(transactionalGraphService.getAllNodes()).hasSize(1);
    Optional<Node> nodeOptional = transactionalGraphService.getPersistentNodeById(1);
    assertThat(nodeOptional.get().getId()).isEqualTo(1);
    assertThat(nodeOptional.get().getLabel()).isEqualTo(new Label("Person"));
    assertThat(nodeOptional.get().hasProperty("name")).isTrue();
    assertThat(nodeOptional.get().getProperty("name").get()).isEqualTo(new Property("name", STRING, "Adam"));
    assertThat(nodeOptional.get().getRelationships()).isEmpty();
}

[Buggy Hunk]
assertThat(transactionalGraphService.getAllNodes()).hasSize(1);

[Patch]
assertThat(transactionalGraphService.getAllPersistentNodes()).hasSize(1);

[Demonstration 3]

[Buggy Method]
protected void registerDataSink(DataSink dataSink, SensorType requestedSensor) throws IOException {
    // dataSink *must not be* this, as that would lead to infinite recursion
    if (this == dataSink)
        throw new InvalidParameterException("A Server subclass cannot register itself as a data sink.");
    // add new data sink list if the requested sensor type has no sinks yet
    if (!mDataSinks.containsKey(requestedSensor))
        mDataSinks.put(requestedSensor, new HashSet<>());
    // add the new sink to the list of sink for the sensor
    mDataSinks.get(requestedSensor).add(dataSink);
    // force resetting the sensors on the client
    mClientHandlerFactory.updateSensors(mDataSinks.keySet());
}

[Buggy Hunk]
mDataSinks.put(requestedSensor, new HashSet<>());

[Patch]
mDataSinks.put(requestedSensor, new HashSet<DataSink>());