This is an automated email from the ASF dual-hosted git repository. coheigea pushed a commit to branch camel-2.25.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit e577b4965a6e00a15a6f560c4e9e2d2327961245 Author: Colm O hEigeartaigh <cohei...@apache.org> AuthorDate: Tue Feb 18 13:19:48 2020 +0000 CAMEL-14532 - Fix checkstyle warnings --- .../custom/CustomClassLoaderConstructor.java | 30 +++++------ .../component/snakeyaml/custom/CustomComposer.java | 36 ++++++------- .../snakeyaml/custom/CustomConstructor.java | 30 +++++------ .../snakeyaml/custom/CustomSafeConstructor.java | 30 +++++------ .../camel/component/snakeyaml/custom/Yaml.java | 62 ++++++++++++---------- .../component/snakeyaml/SnakeYAMLDoSTest.java | 7 ++- 6 files changed, 98 insertions(+), 97 deletions(-) diff --git a/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/CustomClassLoaderConstructor.java b/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/CustomClassLoaderConstructor.java index 7efabe1..163ebdf 100644 --- a/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/CustomClassLoaderConstructor.java +++ b/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/CustomClassLoaderConstructor.java @@ -1,20 +1,18 @@ -/** - * 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 +/* + * 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 + * 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. + * 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.camel.component.snakeyaml.custom; @@ -55,7 +53,7 @@ public class CustomClassLoaderConstructor extends org.yaml.snakeyaml.constructor Object key = constructObject(keyNode); if (key != null) { try { - key.hashCode();// check circular dependencies + key.hashCode(); // check circular dependencies } catch (Exception e) { throw new CustomConstructorException("while constructing a mapping", node.getStartMark(), "found unacceptable key " + key, diff --git a/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/CustomComposer.java b/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/CustomComposer.java index 74dfcc4..b97bcdf 100644 --- a/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/CustomComposer.java +++ b/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/CustomComposer.java @@ -1,20 +1,18 @@ -/** - * 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 +/* + * 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 + * 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. + * 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.camel.component.snakeyaml.custom; @@ -60,7 +58,7 @@ public class CustomComposer extends Composer { private final Resolver resolver; private final Map<String, Node> anchors; private final Set<Node> recursiveNodes; - private int nonScalarAliasesCount = 0; + private int nonScalarAliasesCount; private final int maxAliasesForCollections; public CustomComposer(Parser parser, Resolver resolver) { @@ -128,7 +126,7 @@ public class CustomComposer extends Composer { // Ensure that the stream contains no more documents. if (!parser.checkEvent(Event.ID.StreamEnd)) { Event event = parser.getEvent(); - Mark contextMark = document != null ? document.getStartMark(): null; + Mark contextMark = document != null ? document.getStartMark() : null; throw new CustomComposerException("expected a single document in the stream", contextMark, "but found another document", event.getStartMark()); } @@ -138,7 +136,9 @@ public class CustomComposer extends Composer { } private Node composeNode(Node parent) { - if (parent != null) recursiveNodes.add(parent); + if (parent != null) { + recursiveNodes.add(parent); + } final Node node; if (parser.checkEvent(Event.ID.Alias)) { AliasEvent event = (AliasEvent) parser.getEvent(); diff --git a/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/CustomConstructor.java b/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/CustomConstructor.java index 5257742..47aa4e7 100644 --- a/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/CustomConstructor.java +++ b/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/CustomConstructor.java @@ -1,20 +1,18 @@ -/** - * 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 +/* + * 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 + * 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. + * 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.camel.component.snakeyaml.custom; @@ -48,7 +46,7 @@ public class CustomConstructor extends Constructor { Object key = constructObject(keyNode); if (key != null) { try { - key.hashCode();// check circular dependencies + key.hashCode(); // check circular dependencies } catch (Exception e) { throw new CustomConstructorException("while constructing a mapping", node.getStartMark(), "found unacceptable key " + key, diff --git a/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/CustomSafeConstructor.java b/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/CustomSafeConstructor.java index d93d6c5..129718a 100644 --- a/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/CustomSafeConstructor.java +++ b/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/CustomSafeConstructor.java @@ -1,20 +1,18 @@ -/** - * 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 +/* + * 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 + * 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. + * 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.camel.component.snakeyaml.custom; @@ -48,7 +46,7 @@ public class CustomSafeConstructor extends SafeConstructor { Object key = constructObject(keyNode); if (key != null) { try { - key.hashCode();// check circular dependencies + key.hashCode(); // check circular dependencies } catch (Exception e) { throw new CustomConstructorException("while constructing a mapping", node.getStartMark(), "found unacceptable key " + key, diff --git a/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/Yaml.java b/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/Yaml.java index 65ebdf8..983e730 100644 --- a/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/Yaml.java +++ b/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/custom/Yaml.java @@ -1,11 +1,12 @@ -/** - * Copyright (c) 2008, http://www.snakeyaml.org +/* + * 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 * - * Licensed 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 + * 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, @@ -13,8 +14,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* + * Copyright (c) 2008, http://www.snakeyaml.org + */ package org.apache.camel.component.snakeyaml.custom; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.regex.Pattern; + import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.DumperOptions.FlowStyle; import org.yaml.snakeyaml.LoaderOptions; @@ -36,18 +52,6 @@ import org.yaml.snakeyaml.representer.Representer; import org.yaml.snakeyaml.resolver.Resolver; import org.yaml.snakeyaml.serializer.Serializer; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.regex.Pattern; - /** * Public YAML interface. This class is not thread-safe. Which means that all the methods of the same * instance can be called only by one thread. @@ -59,11 +63,11 @@ import java.util.regex.Pattern; */ public class Yaml { protected final Resolver resolver; - private String name; protected BaseConstructor constructor; protected Representer representer; protected DumperOptions dumperOptions; protected LoaderOptions loadingConfig; + private String name; private int maxAliasesForCollections = 50; @@ -121,15 +125,6 @@ public class Yaml { this(constructor, representer, initDumperOptions(representer)); } - private static DumperOptions initDumperOptions(Representer representer) { - DumperOptions dumperOptions = new DumperOptions(); - dumperOptions.setDefaultFlowStyle(representer.getDefaultFlowStyle()); - dumperOptions.setDefaultScalarStyle(representer.getDefaultScalarStyle()); - dumperOptions.setAllowReadOnlyProperties(representer.getPropertyUtils().isAllowReadOnlyProperties()); - dumperOptions.setTimeZone(representer.getTimeZone()); - return dumperOptions; - } - /** * Create Yaml instance. It is safe to create a few instances and use them * in different Threads. @@ -222,6 +217,15 @@ public class Yaml { this.name = "Yaml:" + System.identityHashCode(this); } + private static DumperOptions initDumperOptions(Representer representer) { + DumperOptions dumperOptions = new DumperOptions(); + dumperOptions.setDefaultFlowStyle(representer.getDefaultFlowStyle()); + dumperOptions.setDefaultScalarStyle(representer.getDefaultScalarStyle()); + dumperOptions.setAllowReadOnlyProperties(representer.getPropertyUtils().isAllowReadOnlyProperties()); + dumperOptions.setTimeZone(representer.getTimeZone()); + return dumperOptions; + } + /** * Serialize a Java object into a YAML String. * diff --git a/components/camel-snakeyaml/src/test/java/org/apache/camel/component/snakeyaml/SnakeYAMLDoSTest.java b/components/camel-snakeyaml/src/test/java/org/apache/camel/component/snakeyaml/SnakeYAMLDoSTest.java index 264b3da..6df32a6 100644 --- a/components/camel-snakeyaml/src/test/java/org/apache/camel/component/snakeyaml/SnakeYAMLDoSTest.java +++ b/components/camel-snakeyaml/src/test/java/org/apache/camel/component/snakeyaml/SnakeYAMLDoSTest.java @@ -1,4 +1,4 @@ -/** +/* * 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. @@ -91,7 +91,10 @@ public class SnakeYAMLDoSTest extends CamelTestSupport { // Taken from SnakeYaml test code private String createDump(int size) { Map<String, Object> root = new HashMap<>(); - Map<String, Object> s1, s2, t1, t2; + Map<String, Object> s1; + Map<String, Object> s2; + Map<String, Object> t1; + Map<String, Object> t2; s1 = root; s2 = new HashMap<>(); /*