Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,8 @@ public Class<U> getUserDefinedPredicateClass() {
@Override
public U getUserDefinedPredicate() {
try {
return udpClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
return udpClass.getDeclaredConstructor().newInstance();
} catch (ReflectiveOperationException e) {
throw new RuntimeException(String.format(INSTANTIATION_ERROR_MESSAGE, udpClass), e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ public void consumeStruct(TProtocol protocol, EventBasedThriftReader reader) thr

protected T newObject() {
try {
return c.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
return c.getDeclaredConstructor().newInstance();
} catch (ReflectiveOperationException e) {
throw new RuntimeException(c.getName(), e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ static DecryptionPropertiesFactory loadFactory(Configuration conf) {
}

try {
return (DecryptionPropertiesFactory) decryptionPropertiesFactoryClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
return (DecryptionPropertiesFactory)
decryptionPropertiesFactoryClass.getDeclaredConstructor().newInstance();
} catch (ReflectiveOperationException e) {
throw new BadConfigurationException(
"could not instantiate decryptionPropertiesFactoryClass class: " + decryptionPropertiesFactoryClass,
e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ static EncryptionPropertiesFactory loadFactory(ParquetConfiguration conf) {
}

try {
return (EncryptionPropertiesFactory) encryptionPropertiesFactoryClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
return (EncryptionPropertiesFactory)
encryptionPropertiesFactoryClass.getDeclaredConstructor().newInstance();
} catch (ReflectiveOperationException e) {
throw new BadConfigurationException(
"could not instantiate encryptionPropertiesFactoryClass class: " + encryptionPropertiesFactoryClass,
e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,8 @@ private static KmsClient createAndInitKmsClient(
if (null == kmsClientClass) {
throw new ParquetCryptoRuntimeException("Unspecified " + KMS_CLIENT_CLASS_PROPERTY_NAME);
}
kmsClient = (KmsClient) kmsClientClass.newInstance();
} catch (InstantiationException | IllegalAccessException | BadConfigurationException e) {
kmsClient = (KmsClient) kmsClientClass.getDeclaredConstructor().newInstance();
} catch (ReflectiveOperationException | BadConfigurationException e) {
throw new ParquetCryptoRuntimeException("Could not instantiate KmsClient class: " + kmsClientClass, e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ private static UnboundRecordFilter getUnboundRecordFilterInstance(ParquetConfigu
return null;
}
try {
return (UnboundRecordFilter) clazz.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
return (UnboundRecordFilter) clazz.getDeclaredConstructor().newInstance();
} catch (ReflectiveOperationException e) {
throw new BadConfigurationException("could not instantiate unbound record filter class", e);
}
}
Expand Down Expand Up @@ -332,8 +332,8 @@ public static <T> ReadSupport<T> getReadSupportInstance(Configuration configurat
@SuppressWarnings("unchecked")
static <T> ReadSupport<T> getReadSupportInstance(Class<? extends ReadSupport<T>> readSupportClass) {
try {
return readSupportClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
return readSupportClass.getDeclaredConstructor().newInstance();
} catch (ReflectiveOperationException e) {
throw new BadConfigurationException("could not instantiate read support class", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,9 @@ public WriteSupport<T> getWriteSupport(Configuration configuration) {
Class<?> writeSupportClass = getWriteSupportClass(configuration);
try {
return (WriteSupport<T>) Objects.requireNonNull(writeSupportClass, "writeSupportClass cannot be null")
.getDeclaredConstructor()
.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
} catch (ReflectiveOperationException e) {
throw new BadConfigurationException("could not instantiate write support class: " + writeSupportClass, e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ public WriteContext init(ParquetConfiguration configuration) {
this.configuration = configuration;
if (this.protocolFactory == null) {
try {
this.protocolFactory = getTProtocolFactoryClass(configuration).newInstance();
} catch (InstantiationException | IllegalAccessException e) {
this.protocolFactory = getTProtocolFactoryClass(configuration)
.getDeclaredConstructor()
.newInstance();
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ public TBaseRecordConverter(
@Override
public T readOneRecord(TProtocol protocol) throws TException {
try {
T thriftObject = thriftClass.newInstance();
T thriftObject =
thriftClass.getDeclaredConstructor().newInstance();
thriftObject.read(protocol);
return thriftObject;
} catch (InstantiationException e) {
throw new ParquetDecodingException("Could not instantiate Thrift " + thriftClass, e);
} catch (IllegalAccessException e) {
throw new ParquetDecodingException(
"Thrift class or constructor not public " + thriftClass, e);
} catch (ReflectiveOperationException e) {
throw new ParquetDecodingException("Could not instantiate Thrift " + thriftClass, e);
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void testMapSet() throws Exception {
writeReadCompare(a);
}

private void writeReadCompare(TBase<?, ?> a) throws TException, InstantiationException, IllegalAccessException {
private void writeReadCompare(TBase<?, ?> a) throws TException, ReflectiveOperationException {
ProtocolPipe[] pipes = {
new ProtocolReadToWrite(),
new BufferedProtocolReadToWrite(ThriftSchemaConverter.toStructType((Class<TBase<?, ?>>) a.getClass()))
Expand All @@ -134,7 +134,7 @@ private void writeReadCompare(TBase<?, ?> a) throws TException, InstantiationExc
final ByteArrayOutputStream out = new ByteArrayOutputStream();
a.write(protocol(in));
p.readOne(protocol(new ByteArrayInputStream(in.toByteArray())), protocol(out));
TBase<?, ?> b = a.getClass().newInstance();
TBase<?, ?> b = a.getClass().getDeclaredConstructor().newInstance();
b.read(protocol(new ByteArrayInputStream(out.toByteArray())));

assertThat(b).as(p.getClass().getSimpleName()).isEqualTo(a);
Expand Down Expand Up @@ -372,7 +372,8 @@ public void handleFieldIgnored(TField field) {
assertThat(countingHandler.recordCountOfMissingFields).isEqualTo(1);
assertThat(countingHandler.fieldIgnoredCount).isEqualTo(1);

StructV4WithExtracStructField b = StructV4WithExtracStructField.class.newInstance();
StructV4WithExtracStructField b =
StructV4WithExtracStructField.class.getDeclaredConstructor().newInstance();
b.read(protocol(new ByteArrayInputStream(out.toByteArray())));
assertThat(b.getName()).isEqualTo(dataWithNewSchema.getName());
assertThat(b.getAge()).isEqualTo(dataWithNewSchema.getAge());
Expand Down
Loading