HBASE-4494 AvroServer:: get fails with NPE on a non-existent row
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1179014 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fa6fb56932
commit
2b981abcbb
|
@ -335,6 +335,8 @@ Release 0.92.0 - Unreleased
|
||||||
HBASE-4531 hbase-4454 failsafe broke mvn site; back it out or fix
|
HBASE-4531 hbase-4454 failsafe broke mvn site; back it out or fix
|
||||||
(Akash Ashok)
|
(Akash Ashok)
|
||||||
HBASE-4334 HRegion.get never validates row (Lars Hofhansl)
|
HBASE-4334 HRegion.get never validates row (Lars Hofhansl)
|
||||||
|
HBASE-4494 AvroServer:: get fails with NPE on a non-existent row
|
||||||
|
(Kay Kay)
|
||||||
|
|
||||||
TESTS
|
TESTS
|
||||||
HBASE-4450 test for number of blocks read: to serve as baseline for expected
|
HBASE-4450 test for number of blocks read: to serve as baseline for expected
|
||||||
|
|
|
@ -302,7 +302,8 @@ public class AvroUtil {
|
||||||
// TODO(hammer): Pick one: Timestamp or TimeStamp
|
// TODO(hammer): Pick one: Timestamp or TimeStamp
|
||||||
static public AResult resultToAResult(Result result) {
|
static public AResult resultToAResult(Result result) {
|
||||||
AResult aresult = new AResult();
|
AResult aresult = new AResult();
|
||||||
aresult.row = ByteBuffer.wrap(result.getRow());
|
byte[] row = result.getRow();
|
||||||
|
aresult.row = ByteBuffer.wrap(row != null ? row : new byte[1]);
|
||||||
Schema s = Schema.createArray(AResultEntry.SCHEMA$);
|
Schema s = Schema.createArray(AResultEntry.SCHEMA$);
|
||||||
GenericData.Array<AResultEntry> entries = null;
|
GenericData.Array<AResultEntry> entries = null;
|
||||||
List<KeyValue> resultKeyValues = result.list();
|
List<KeyValue> resultKeyValues = result.list();
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.hadoop.hbase.avro;
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.hadoop.hbase.avro.generated.AResult;
|
||||||
|
import org.apache.hadoop.hbase.client.Result;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
public class TestAvroUtil {
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetEmpty() {
|
||||||
|
Result result = Mockito.mock(Result.class);
|
||||||
|
Mockito.when(result.getRow()).thenReturn(null);
|
||||||
|
//Get on a row, that does not exist, returns a result,
|
||||||
|
//whose row is null.
|
||||||
|
AResult aresult = AvroUtil.resultToAResult(result);
|
||||||
|
Assert.assertNotNull(aresult);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue