Example usage for io.netty.util ReferenceCountUtil releaseLater

List of usage examples for io.netty.util ReferenceCountUtil releaseLater

Introduction

In this page you can find the example usage for io.netty.util ReferenceCountUtil releaseLater.

Prototype

@Deprecated
public static <T> T releaseLater(T msg) 

Source Link

Document

Schedules the specified object to be released when the caller thread terminates.

Usage

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@After
public void deleteData() {
    RemoveRequest remove = new RemoveRequest(testSubKey, bucket());
    RemoveResponse response = cluster().<RemoveResponse>send(remove).toBlocking().single();
    boolean removedSubkey = response.status().isSuccess();
    ReferenceCountUtil.releaseLater(response.content());

    remove = new RemoveRequest(testInsertionSubKey, bucket());
    response = cluster().<RemoveResponse>send(remove).toBlocking().single();
    boolean removedInsertionSubkey = response.status().isSuccess()
            || response.status().equals(ResponseStatus.NOT_EXISTS);
    ReferenceCountUtil.releaseLater(response.content());

    remove = new RemoveRequest(testArrayRoot, bucket());
    response = cluster().<RemoveResponse>send(remove).toBlocking().single();
    boolean removedArraySubkey = response.status().isSuccess();
    ReferenceCountUtil.releaseLater(response.content());

    remove = new RemoveRequest(testComplexSubArray, bucket());
    response = cluster().<RemoveResponse>send(remove).toBlocking().single();
    boolean removeComplexSubArray = response.status().isSuccess();
    ReferenceCountUtil.releaseLater(response.content());

    assertTrue("Couldn't remove " + testSubKey, removedSubkey);
    assertTrue("Couldn't remove " + testInsertionSubKey, removedInsertionSubkey);
    assertTrue("Couldn't remove " + testArrayRoot, removedArraySubkey);
    assertTrue("Couldn't remove " + testComplexSubArray, removeComplexSubArray);
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldSubGetValueInExistingDocumentObject() throws Exception {
    String subValuePath = "sub.value";

    SubGetRequest valueRequest = new SubGetRequest(testSubKey, subValuePath, bucket());
    SimpleSubdocResponse valueResponse = cluster().<SimpleSubdocResponse>send(valueRequest).toBlocking()
            .single();// w ww . j a v  a2  s  .c o m
    String raw = valueResponse.content().toString(CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(valueResponse.content());
    assertNotNull(raw);
    assertEquals("\"subStringValue\"", raw);
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldSubGetValueInExistingDocumentArray() throws Exception {
    String subArrayPath = "sub.array[1]";

    SubGetRequest arrayRequest = new SubGetRequest(testSubKey, subArrayPath, bucket());
    SimpleSubdocResponse arrayResponse = cluster().<SimpleSubdocResponse>send(arrayRequest).toBlocking()
            .single();/*  www. java  2 s. com*/
    String raw = arrayResponse.content().toString(CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(arrayResponse.content());
    assertNotNull(raw);
    assertEquals("2", raw);
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldFailSubGetIfPathDoesntExist() {
    String wrongPath = "sub.arra[1]";

    SubGetRequest badRequest = new SubGetRequest(testSubKey, wrongPath, bucket());
    SimpleSubdocResponse response = cluster().<SimpleSubdocResponse>send(badRequest).toBlocking().single();
    ReferenceCountUtil.releaseLater(response.content());

    assertFalse(response.status().isSuccess());
    assertEquals(ResponseStatus.SUBDOC_PATH_NOT_FOUND, response.status());
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldDictUpsertInExistingDocumentObject() {
    String subPath = "sub.value";
    ByteBuf fragment = Unpooled.copiedBuffer("\"mutated\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    //verify initial state
    assertMutation(testSubKey, jsonContent);

    //mutate/*  w ww.j av  a2  s  .  com*/
    SubDictUpsertRequest upsertRequest = new SubDictUpsertRequest(testSubKey, subPath, fragment, bucket());
    SimpleSubdocResponse upsertResponse = cluster().<SimpleSubdocResponse>send(upsertRequest).toBlocking()
            .single();
    ReferenceCountUtil.releaseLater(upsertResponse.content());
    assertTrue(upsertResponse.status().isSuccess());

    //verify mutated state
    assertMutation(testSubKey, jsonContent.replace("subStringValue", "mutated"));
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldReturnPathInvalidOnDictUpsertInArray() {
    String subPath = "sub.array[1]";
    ByteBuf fragment = Unpooled.copiedBuffer("\"mutated\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    //mutate/*from  www . ja va  2s  .com*/
    SubDictUpsertRequest upsertRequest = new SubDictUpsertRequest(testSubKey, subPath, fragment, bucket());
    SimpleSubdocResponse upsertResponse = cluster().<SimpleSubdocResponse>send(upsertRequest).toBlocking()
            .single();
    ReferenceCountUtil.releaseLater(upsertResponse.content());
    assertFalse(upsertResponse.status().isSuccess());
    assertEquals(0, upsertResponse.content().readableBytes());
    assertEquals(ResponseStatus.SUBDOC_PATH_INVALID, upsertResponse.status());
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldGetMutationTokenWithMutation() throws Exception {
    String subPath = "sub.value";
    ByteBuf fragment = Unpooled.copiedBuffer("\"mutated\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    SubDictUpsertRequest upsertRequest = new SubDictUpsertRequest(testSubKey, subPath, fragment, bucket());
    SimpleSubdocResponse upsertResponse = cluster().<SimpleSubdocResponse>send(upsertRequest).toBlocking()
            .single();//from w  ww .j ava 2s. com
    ReferenceCountUtil.releaseLater(upsertResponse.content());
    assertValidMetadata(upsertResponse.mutationToken());
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldNotGetMutationTokenWithGet() throws Exception {
    String subPath = "sub.value";
    ByteBuf fragment = Unpooled.copiedBuffer("\"mutated\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    SubGetRequest getRequest = new SubGetRequest(testSubKey, subPath, bucket());
    SimpleSubdocResponse response = cluster().<SimpleSubdocResponse>send(getRequest).toBlocking().single();
    ReferenceCountUtil.releaseLater(response.content());
    assertNull(response.mutationToken());
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldDictAddOnSubObject() {
    String subPath = "sub.otherValue";
    ByteBuf fragment = Unpooled.copiedBuffer("\"inserted\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    //mutate//from   w  ww.  jav a2s . c om
    SubDictAddRequest insertRequest = new SubDictAddRequest(testSubKey, subPath, fragment, bucket());
    SimpleSubdocResponse insertResponse = cluster().<SimpleSubdocResponse>send(insertRequest).toBlocking()
            .single();
    ReferenceCountUtil.releaseLater(insertResponse.content());
    assertTrue(insertResponse.status().isSuccess());
    assertEquals(0, insertResponse.content().readableBytes());

    //check the insertion at the end of "sub" object
    String expected = "{\"value\":\"stringValue\", \"sub\": {\"value\": \"subStringValue\",\"array\": [\"array1\", 2, true]"
            + ",\"otherValue\":\"inserted\"}}";
    assertMutation(testSubKey, expected);
}

From source file:com.couchbase.client.core.cluster.SubdocumentMessageTest.java

License:Apache License

@Test
public void shouldReturnPathExistOnDictAddOnSubValue() {
    String subPath = "sub.value";
    ByteBuf fragment = Unpooled.copiedBuffer("\"mutated\"", CharsetUtil.UTF_8);
    ReferenceCountUtil.releaseLater(fragment);

    //mutate//from   www.j a  v  a2s.  c  o  m
    SubDictAddRequest insertRequest = new SubDictAddRequest(testSubKey, subPath, fragment, bucket());
    SimpleSubdocResponse insertResponse = cluster().<SimpleSubdocResponse>send(insertRequest).toBlocking()
            .single();
    ReferenceCountUtil.releaseLater(insertResponse.content());
    assertFalse(insertResponse.status().isSuccess());
    assertEquals(0, insertResponse.content().readableBytes());
    assertEquals(ResponseStatus.SUBDOC_PATH_EXISTS, insertResponse.status());
}