You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2015/10/28 23:16:35 UTC
[1/2] jclouds git commit: Convert logback.xml to unix format
Repository: jclouds
Updated Branches:
refs/heads/master 592a4e7cc -> afd3c322a
Convert logback.xml to unix format
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/0e7283e1
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/0e7283e1
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/0e7283e1
Branch: refs/heads/master
Commit: 0e7283e1912d93a9ac4a864c8f16f6735fa5e03c
Parents: 592a4e7
Author: Ignasi Barrera <na...@apache.org>
Authored: Wed Oct 28 23:15:28 2015 +0100
Committer: Ignasi Barrera <na...@apache.org>
Committed: Wed Oct 28 23:15:28 2015 +0100
----------------------------------------------------------------------
apis/oauth/src/test/resources/logback.xml | 112 ++++++++++++-------------
1 file changed, 56 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/0e7283e1/apis/oauth/src/test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/apis/oauth/src/test/resources/logback.xml b/apis/oauth/src/test/resources/logback.xml
index 3a640aa..29fa790 100644
--- a/apis/oauth/src/test/resources/logback.xml
+++ b/apis/oauth/src/test/resources/logback.xml
@@ -1,56 +1,56 @@
-<?xml version="1.0"?>
-<!--
-
- 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.
-
--->
-<configuration scan="false">
- <appender name="FILE" class="ch.qos.logback.core.FileAppender">
- <file>target/test-data/jclouds.log</file>
-
- <encoder>
- <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
- </encoder>
- </appender>
-
- <appender name="WIREFILE" class="ch.qos.logback.core.FileAppender">
- <file>target/test-data/jclouds-wire.log</file>
-
- <encoder>
- <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
- </encoder>
- </appender>
-
- <root>
- <level value="warn" />
- </root>
-
- <logger name="org.jclouds">
- <level value="DEBUG" />
- <appender-ref ref="FILE" />
- </logger>
-
- <logger name="jclouds.wire">
- <level value="DEBUG" />
- <appender-ref ref="WIREFILE" />
- </logger>
-
- <logger name="jclouds.headers">
- <level value="DEBUG" />
- <appender-ref ref="WIREFILE" />
- </logger>
-
-</configuration>
+<?xml version="1.0"?>
+<!--
+
+ 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.
+
+-->
+<configuration scan="false">
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>target/test-data/jclouds.log</file>
+
+ <encoder>
+ <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
+ </encoder>
+ </appender>
+
+ <appender name="WIREFILE" class="ch.qos.logback.core.FileAppender">
+ <file>target/test-data/jclouds-wire.log</file>
+
+ <encoder>
+ <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root>
+ <level value="warn" />
+ </root>
+
+ <logger name="org.jclouds">
+ <level value="DEBUG" />
+ <appender-ref ref="FILE" />
+ </logger>
+
+ <logger name="jclouds.wire">
+ <level value="DEBUG" />
+ <appender-ref ref="WIREFILE" />
+ </logger>
+
+ <logger name="jclouds.headers">
+ <level value="DEBUG" />
+ <appender-ref ref="WIREFILE" />
+ </logger>
+
+</configuration>
[2/2] jclouds git commit: JCLOUDS-1030: Ignore synthetic members in
serialization strategies
Posted by na...@apache.org.
JCLOUDS-1030: Ignore synthetic members in serialization strategies
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/afd3c322
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/afd3c322
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/afd3c322
Branch: refs/heads/master
Commit: afd3c322a9d574a27526b479654b97a3142b99cf
Parents: 0e7283e
Author: Ignasi Barrera <na...@apache.org>
Authored: Tue Oct 27 22:08:08 2015 +0100
Committer: Ignasi Barrera <na...@apache.org>
Committed: Wed Oct 28 23:15:41 2015 +0100
----------------------------------------------------------------------
.../jclouds/json/internal/NamingStrategies.java | 47 +++++++++++++++++---
1 file changed, 40 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/afd3c322/core/src/main/java/org/jclouds/json/internal/NamingStrategies.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/json/internal/NamingStrategies.java b/core/src/main/java/org/jclouds/json/internal/NamingStrategies.java
index cf3c5ac..ddee5dd 100644
--- a/core/src/main/java/org/jclouds/json/internal/NamingStrategies.java
+++ b/core/src/main/java/org/jclouds/json/internal/NamingStrategies.java
@@ -18,8 +18,10 @@ package org.jclouds.json.internal;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Predicates.in;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.get;
+import static com.google.common.collect.Iterables.size;
import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Iterables.tryFind;
import static org.jclouds.reflect.Reflection2.constructors;
@@ -30,6 +32,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
import javax.inject.Named;
@@ -44,6 +47,7 @@ import com.google.common.base.Supplier;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Maps;
import com.google.common.reflect.Invokable;
+import com.google.common.reflect.Parameter;
import com.google.common.reflect.TypeToken;
import com.google.gson.FieldNamingStrategy;
import com.google.gson.annotations.SerializedName;
@@ -178,11 +182,30 @@ public class NamingStrategies {
SerializedNames names = target.getAnnotation(SerializedNames.class);
if (names != null && target.isStatic()) { // == factory method
// Fields and constructor params are written by AutoValue in same order as methods are declared.
- // By contract, SerializedNames factory methods must declare its names in the same order,
- Field[] fields = f.getDeclaringClass().getDeclaredFields();
- checkState(fields.length == names.value().length, "Incorrect number of names on " + names);
- for (int i = 0; i < fields.length; i++) {
- if (fields[i].equals(f)) {
+ // By contract, SerializedNames factory methods must declare its names in the same order.
+ List<Field> declaredFields = Arrays.asList(f.getDeclaringClass().getDeclaredFields());
+ // Instrumentation libraries, such as JaCoCo might introduce synthetic fields to the class.
+ // We should ignore them
+ Iterable<Field> fields = filter(declaredFields, new Predicate<Field>() {
+ @Override
+ public boolean apply(Field input) {
+ return !input.isSynthetic();
+ }
+ });
+ int numFields = size(fields);
+ if (numFields != names.value().length) {
+ String message = "Incorrect number of names on %s. Class [%s]. Annotation config: [%s]. Fields in object; [%s]";
+ String types = Joiner.on(",").join(transform(fields, new Function<Field, String>() {
+ @Override
+ public String apply(Field input) {
+ return input.getType().getName();
+ }
+ }));
+ throw new IllegalStateException(String.format(message, names, f.getDeclaringClass().getName(),
+ Joiner.on(",").join(names.value()), types));
+ }
+ for (int i = 0; i < numFields; i++) {
+ if (get(fields, i).equals(f)) {
return names.value()[i];
}
}
@@ -259,7 +282,17 @@ public class NamingStrategies {
? c.getAnnotation(SerializedNames.class).value()
: c.getAnnotation(ConstructorProperties.class).value();
- checkArgument(names.length == c.getParameters().size(), "Incorrect count of names on annotation of %s", c);
+ if (names.length != c.getParameters().size()) {
+ String message = "Incorrect count of names on annotation of %s. Class: [%s]. Annotation config: [%s]. Parameters; [%s]";
+ String types = Joiner.on(",").join(transform(c.getParameters(), new Function<Parameter, String>() {
+ @Override
+ public String apply(Parameter input) {
+ return input.getClass().getName();
+ }
+ }));
+ throw new IllegalArgumentException(String.format(message, c, c.getDeclaringClass().getName(),
+ Joiner.on(",").join(names), types));
+ }
if (names != null && names.length > index) {
name = names[index];