You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by se...@apache.org on 2015/10/16 18:08:44 UTC
[17/24] flink git commit: [hotfix] [core] TypeExtractor correctly
handles non-public types as generic types (rather than failing with an
exception)
[hotfix] [core] TypeExtractor correctly handles non-public types as generic types (rather than failing with an exception)
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/b81598ef
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/b81598ef
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/b81598ef
Branch: refs/heads/master
Commit: b81598ef25176c5b712975ef25c9bfe4ef0f16b3
Parents: d5a016c
Author: Stephan Ewen <se...@apache.org>
Authored: Fri Oct 9 19:31:30 2015 +0200
Committer: Stephan Ewen <se...@apache.org>
Committed: Fri Oct 16 15:26:10 2015 +0200
----------------------------------------------------------------------
.../apache/flink/api/java/typeutils/TypeExtractor.java | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/b81598ef/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java
----------------------------------------------------------------------
diff --git a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java
index 252842e..1dec90b 100644
--- a/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java
+++ b/flink-java/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java
@@ -1239,7 +1239,7 @@ public class TypeExtractor {
// check for subclasses of Tuple
if (Tuple.class.isAssignableFrom(clazz)) {
if(clazz == Tuple0.class) {
- return new TupleTypeInfo(Tuple0.class, new TypeInformation<?>[0]);
+ return new TupleTypeInfo(Tuple0.class);
}
throw new InvalidTypesException("Type information extraction for tuples (except Tuple0) cannot be done based on the class.");
}
@@ -1352,17 +1352,22 @@ public class TypeExtractor {
protected <OUT, IN1, IN2> TypeInformation<OUT> analyzePojo(Class<OUT> clazz, ArrayList<Type> typeHierarchy,
ParameterizedType parameterizedType, TypeInformation<IN1> in1Type, TypeInformation<IN2> in2Type) {
+ if (!Modifier.isPublic(clazz.getModifiers())) {
+ LOG.info("Class " + clazz.getName() + " is not public, cannot treat it as a POJO type. Will be handled as GenericType");
+ return new GenericTypeInfo<OUT>(clazz);
+ }
+
// add the hierarchy of the POJO itself if it is generic
if (parameterizedType != null) {
getTypeHierarchy(typeHierarchy, parameterizedType, Object.class);
}
// create a type hierarchy, if the incoming only contains the most bottom one or none.
- else if(typeHierarchy.size() <= 1) {
+ else if (typeHierarchy.size() <= 1) {
getTypeHierarchy(typeHierarchy, clazz, Object.class);
}
List<Field> fields = getAllDeclaredFields(clazz);
- if(fields.size() == 0) {
+ if (fields.size() == 0) {
LOG.info("No fields detected for " + clazz + ". Cannot be used as a PojoType. Will be handled as GenericType");
return new GenericTypeInfo<OUT>(clazz);
}