Skip to content

Commit 6a670e1

Browse files
committed
add supplymentary data
1 parent 4645753 commit 6a670e1

180 files changed

Lines changed: 34398 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FLUME-1160: ComponentConfigurationFactory catches NullPointerException
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
diff --git a/flume-ng-configuration/src/main/java/org/apache/flume/conf/ComponentConfigurationFactory.java b/flume-ng-configuration/src/main/java/org/apache/flume/conf/ComponentConfigurationFactory.java
2+
index c495cde..6c151dc 100644
3+
--- a/flume-ng-configuration/src/main/java/org/apache/flume/conf/ComponentConfigurationFactory.java
4+
+++ b/flume-ng-configuration/src/main/java/org/apache/flume/conf/ComponentConfigurationFactory.java
5+
@@ -67,2 +66,0 @@ public class ComponentConfigurationFactory {
6+
- } catch (NullPointerException e1) {
7+
- return null;
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with this
4+
* work for additional information regarding copyright ownership. The ASF
5+
* licenses this file to you under the Apache License, Version 2.0 (the
6+
* "License"); you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations under
15+
* the License.
16+
*/
17+
package org.apache.flume.conf;
18+
19+
import org.apache.flume.conf.ComponentConfiguration.ComponentType;
20+
import org.apache.flume.conf.source.SourceConfiguration.SourceConfigurationType;
21+
import org.apache.flume.conf.sink.SinkGroupConfiguration;
22+
import org.apache.flume.conf.sink.SinkConfiguration.SinkConfigurationType;
23+
import org.apache.flume.conf.sink.SinkProcessorConfiguration.SinkProcessorConfigurationType;
24+
import org.apache.flume.conf.channel.ChannelSelectorConfiguration.ChannelSelectorConfigurationType;
25+
import org.apache.flume.conf.channel.ChannelConfiguration.ChannelConfigurationType;
26+
27+
public class ComponentConfigurationFactory {
28+
@SuppressWarnings("unchecked")
29+
public static ComponentConfiguration
30+
create(String name, String type, ComponentType component)
31+
throws ConfigurationException {
32+
Class<? extends ComponentConfiguration> confType = null;
33+
34+
if (type == null) {
35+
throw new ConfigurationException(
36+
"Cannot create component without knowing its type!");
37+
}
38+
try {
39+
confType = (Class<? extends ComponentConfiguration>) Class.forName(type);
40+
return confType.getConstructor(String.class).newInstance(type);
41+
} catch (Exception e) {
42+
try {
43+
type = type.toUpperCase();
44+
switch(component){
45+
case SOURCE:
46+
return SourceConfigurationType.valueOf(type.toUpperCase())
47+
.getConfiguration(name);
48+
case SINK:
49+
return SinkConfigurationType.valueOf(type.toUpperCase())
50+
.getConfiguration(name);
51+
case CHANNEL:
52+
return ChannelConfigurationType.valueOf(type.toUpperCase())
53+
.getConfiguration(name);
54+
case SINK_PROCESSOR:
55+
return SinkProcessorConfigurationType.valueOf(type.toUpperCase())
56+
.getConfiguration(name);
57+
case CHANNELSELECTOR:
58+
return ChannelSelectorConfigurationType.valueOf(type.toUpperCase())
59+
.getConfiguration(name);
60+
case SINKGROUP:
61+
return new SinkGroupConfiguration(name);
62+
default:
63+
throw new ConfigurationException(
64+
"Cannot create configuration. Unknown Type specified: " +
65+
type);
66+
}
67+
} catch (Exception e2) {
68+
throw new ConfigurationException("Could not create configuration!", e);
69+
}
70+
}
71+
}
72+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with this
4+
* work for additional information regarding copyright ownership. The ASF
5+
* licenses this file to you under the Apache License, Version 2.0 (the
6+
* "License"); you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations under
15+
* the License.
16+
*/
17+
package org.apache.flume.conf;
18+
19+
import org.apache.flume.conf.ComponentConfiguration.ComponentType;
20+
import org.apache.flume.conf.source.SourceConfiguration.SourceConfigurationType;
21+
import org.apache.flume.conf.sink.SinkGroupConfiguration;
22+
import org.apache.flume.conf.sink.SinkConfiguration.SinkConfigurationType;
23+
import org.apache.flume.conf.sink.SinkProcessorConfiguration.SinkProcessorConfigurationType;
24+
import org.apache.flume.conf.channel.ChannelSelectorConfiguration.ChannelSelectorConfigurationType;
25+
import org.apache.flume.conf.channel.ChannelConfiguration.ChannelConfigurationType;
26+
27+
public class ComponentConfigurationFactory {
28+
@SuppressWarnings("unchecked")
29+
public static ComponentConfiguration
30+
create(String name, String type, ComponentType component)
31+
throws ConfigurationException {
32+
Class<? extends ComponentConfiguration> confType = null;
33+
34+
if (type == null) {
35+
throw new ConfigurationException(
36+
"Cannot create component without knowing its type!");
37+
}
38+
try {
39+
confType = (Class<? extends ComponentConfiguration>) Class.forName(type);
40+
return confType.getConstructor(String.class).newInstance(type);
41+
} catch (Exception e) {
42+
try {
43+
type = type.toUpperCase();
44+
switch(component){
45+
case SOURCE:
46+
return SourceConfigurationType.valueOf(type.toUpperCase())
47+
.getConfiguration(name);
48+
case SINK:
49+
return SinkConfigurationType.valueOf(type.toUpperCase())
50+
.getConfiguration(name);
51+
case CHANNEL:
52+
return ChannelConfigurationType.valueOf(type.toUpperCase())
53+
.getConfiguration(name);
54+
case SINK_PROCESSOR:
55+
return SinkProcessorConfigurationType.valueOf(type.toUpperCase())
56+
.getConfiguration(name);
57+
case CHANNELSELECTOR:
58+
return ChannelSelectorConfigurationType.valueOf(type.toUpperCase())
59+
.getConfiguration(name);
60+
case SINKGROUP:
61+
return new SinkGroupConfiguration(name);
62+
default:
63+
throw new ConfigurationException(
64+
"Cannot create configuration. Unknown Type specified: " +
65+
type);
66+
}
67+
} catch (NullPointerException e1) {
68+
return null;
69+
} catch (Exception e2) {
70+
throw new ConfigurationException("Could not create configuration!", e);
71+
}
72+
}
73+
}
74+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Id:140
2+
SATName:Genesis
3+
modifiedFPath:flume-ng-configuration/src/main/java/org/apache/flume/conf/ComponentConfigurationFactory.java
4+
comSha:b0e017b0e396242c76d49453b2fb5c426325ed96
5+
parentComSha:b0e017b0e396242c76d49453b2fb5c426325ed96^1
6+
githubUrl:https://github.com/apache/flume
7+
repoName:apache#flume
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Don't throw exception here, just return null instead.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/structr-core/src/main/java/org/structr/core/parser/ArrayExpression.java b/structr-core/src/main/java/org/structr/core/parser/ArrayExpression.java
2+
index 8a4e153..d2addb4 100644
3+
--- a/structr-core/src/main/java/org/structr/core/parser/ArrayExpression.java
4+
+++ b/structr-core/src/main/java/org/structr/core/parser/ArrayExpression.java
5+
@@ -82,0 +83,4 @@ public class ArrayExpression extends Expression {
6+
+ if (value == null) {
7+
+ return null;
8+
+ }
9+
+
10+
@@ -86 +90 @@ public class ArrayExpression extends Expression {
11+
- if (value != null && (value instanceof Collection || value.getClass().isArray())) {
12+
+ if (value instanceof Collection || value.getClass().isArray()) {
13+
@@ -92 +96 @@ public class ArrayExpression extends Expression {
14+
- throw new FrameworkException(422, "Invalid expression: expected collection, found " + (value != null ? value.getClass().getSimpleName() : "null") + ".");
15+
+ throw new FrameworkException(422, "Invalid expression: expected collection, found " + value.getClass().getSimpleName() + ".");
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/**
2+
* Copyright (C) 2010-2014 Morgner UG (haftungsbeschränkt)
3+
*
4+
* This file is part of Structr <http://structr.org>.
5+
*
6+
* Structr is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* Structr is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with Structr. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
package org.structr.core.parser;
20+
21+
import java.util.Collection;
22+
import org.apache.commons.collections.CollectionUtils;
23+
import org.structr.common.SecurityContext;
24+
import org.structr.common.error.FrameworkException;
25+
import org.structr.core.GraphObject;
26+
import org.structr.schema.action.ActionContext;
27+
28+
/**
29+
*
30+
* @author Christian Morgner
31+
*/
32+
33+
public class ArrayExpression extends Expression {
34+
35+
@Override
36+
public String toString() {
37+
38+
final StringBuilder buf = new StringBuilder();
39+
40+
buf.append("[");
41+
42+
for (final Expression expr : expressions) {
43+
buf.append(expr.toString());
44+
}
45+
buf.append("]");
46+
47+
return buf.toString();
48+
}
49+
50+
51+
@Override
52+
public void add(final Expression expression) throws FrameworkException {
53+
54+
if (!expressions.isEmpty()) {
55+
throw new FrameworkException(422, "Invalid expression: expected ], found another expression.");
56+
}
57+
58+
super.add(expression);
59+
}
60+
61+
@Override
62+
public Object evaluate(final SecurityContext securityContext, final ActionContext ctx, final GraphObject entity) throws FrameworkException {
63+
64+
switch (expressions.size()) {
65+
66+
case 0:
67+
throw new FrameworkException(422, "Invalid expression: expected expression, found ].");
68+
69+
case 1:
70+
final Object value = expressions.get(0).evaluate(securityContext, ctx, entity);
71+
if (value instanceof Number) {
72+
73+
return ((Number)value).intValue();
74+
}
75+
}
76+
77+
return null;
78+
}
79+
80+
@Override
81+
public Object transform(final SecurityContext securityContext, final ActionContext ctx, final GraphObject entity, final Object value) throws FrameworkException {
82+
83+
if (value == null) {
84+
return null;
85+
}
86+
87+
final Integer index = (Integer)evaluate(securityContext, ctx, entity);
88+
if (index != null) {
89+
90+
if (value instanceof Collection || value.getClass().isArray()) {
91+
92+
return CollectionUtils.get(value, index);
93+
94+
} else {
95+
96+
throw new FrameworkException(422, "Invalid expression: expected collection, found " + value.getClass().getSimpleName() + ".");
97+
}
98+
99+
} else {
100+
101+
throw new FrameworkException(422, "Invalid expression: invalid array index: null.");
102+
}
103+
}
104+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/**
2+
* Copyright (C) 2010-2014 Morgner UG (haftungsbeschränkt)
3+
*
4+
* This file is part of Structr <http://structr.org>.
5+
*
6+
* Structr is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as
8+
* published by the Free Software Foundation, either version 3 of the
9+
* License, or (at your option) any later version.
10+
*
11+
* Structr is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with Structr. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
package org.structr.core.parser;
20+
21+
import java.util.Collection;
22+
import org.apache.commons.collections.CollectionUtils;
23+
import org.structr.common.SecurityContext;
24+
import org.structr.common.error.FrameworkException;
25+
import org.structr.core.GraphObject;
26+
import org.structr.schema.action.ActionContext;
27+
28+
/**
29+
*
30+
* @author Christian Morgner
31+
*/
32+
33+
public class ArrayExpression extends Expression {
34+
35+
@Override
36+
public String toString() {
37+
38+
final StringBuilder buf = new StringBuilder();
39+
40+
buf.append("[");
41+
42+
for (final Expression expr : expressions) {
43+
buf.append(expr.toString());
44+
}
45+
buf.append("]");
46+
47+
return buf.toString();
48+
}
49+
50+
51+
@Override
52+
public void add(final Expression expression) throws FrameworkException {
53+
54+
if (!expressions.isEmpty()) {
55+
throw new FrameworkException(422, "Invalid expression: expected ], found another expression.");
56+
}
57+
58+
super.add(expression);
59+
}
60+
61+
@Override
62+
public Object evaluate(final SecurityContext securityContext, final ActionContext ctx, final GraphObject entity) throws FrameworkException {
63+
64+
switch (expressions.size()) {
65+
66+
case 0:
67+
throw new FrameworkException(422, "Invalid expression: expected expression, found ].");
68+
69+
case 1:
70+
final Object value = expressions.get(0).evaluate(securityContext, ctx, entity);
71+
if (value instanceof Number) {
72+
73+
return ((Number)value).intValue();
74+
}
75+
}
76+
77+
return null;
78+
}
79+
80+
@Override
81+
public Object transform(final SecurityContext securityContext, final ActionContext ctx, final GraphObject entity, final Object value) throws FrameworkException {
82+
83+
final Integer index = (Integer)evaluate(securityContext, ctx, entity);
84+
if (index != null) {
85+
86+
if (value != null && (value instanceof Collection || value.getClass().isArray())) {
87+
88+
return CollectionUtils.get(value, index);
89+
90+
} else {
91+
92+
throw new FrameworkException(422, "Invalid expression: expected collection, found " + (value != null ? value.getClass().getSimpleName() : "null") + ".");
93+
}
94+
95+
} else {
96+
97+
throw new FrameworkException(422, "Invalid expression: invalid array index: null.");
98+
}
99+
}
100+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Id:158
2+
SATName:Genesis
3+
modifiedFPath:structr-core/src/main/java/org/structr/core/parser/ArrayExpression.java
4+
comSha:fa57be3dc337982f8752f68ad7e5404135c49b95
5+
parentComSha:fa57be3dc337982f8752f68ad7e5404135c49b95^1
6+
githubUrl:https://github.com/structr/structr
7+
repoName:structr#structr

0 commit comments

Comments
 (0)