|
| 1 | +/* |
| 2 | + * Copyright 2018 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.elasticsearch.bootstrap; |
| 18 | + |
| 19 | +import java.io.IOException; |
| 20 | +import java.net.URISyntaxException; |
| 21 | +import java.net.URL; |
| 22 | +import java.util.Collections; |
| 23 | +import java.util.Set; |
| 24 | +import java.util.function.Consumer; |
| 25 | + |
| 26 | +/** |
| 27 | + * No words – No words can describe this piece of code and why we cannot opt-in/opt-out from JarHell check. |
| 28 | + * <p/> |
| 29 | + * Elasticsearch wants to raise awareness if there are two classes with the exact same name (class name and package |
| 30 | + * name) to avoid downstream issues. Turns out, in some case, such as Java 9 module descriptors, it's perfectly fine to |
| 31 | + * have exactly same class names (such as {@code module-info.class}) yet JarHell goes awry and prevents startup. |
| 32 | + * <p> |
| 33 | + * This class is here to be loaded before ES's JarHell class and to anyone that wants to survive JarHell, leave it here |
| 34 | + * or you will die a slow and painful death. |
| 35 | + * <p> |
| 36 | + * Oh, by the way: If Elasticsearch decides to upgrade JarHell with new method signatures, we should adapt to these. |
| 37 | + * |
| 38 | + * @author Mark Paluch |
| 39 | + */ |
| 40 | +public class JarHell { |
| 41 | + |
| 42 | + private JarHell() {} |
| 43 | + |
| 44 | + /** |
| 45 | + * Empty stub. Leave it here or you will die a slow and painful death. |
| 46 | + * |
| 47 | + * @param output |
| 48 | + * @throws IOException |
| 49 | + * @throws URISyntaxException |
| 50 | + */ |
| 51 | + public static void checkJarHell(Consumer<String> output) throws IOException, URISyntaxException {} |
| 52 | + |
| 53 | + /** |
| 54 | + * Empty stub. Leave it here or you will die a slow and painful death. |
| 55 | + * |
| 56 | + * @return |
| 57 | + */ |
| 58 | + public static Set<URL> parseClassPath() { |
| 59 | + return Collections.emptySet(); |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * Empty stub. Leave it here or you will die a slow and painful death. |
| 64 | + * |
| 65 | + * @param urls |
| 66 | + * @param output |
| 67 | + * @throws URISyntaxException |
| 68 | + * @throws IOException |
| 69 | + */ |
| 70 | + public static void checkJarHell(Set<URL> urls, Consumer<String> output) throws URISyntaxException, IOException {} |
| 71 | + |
| 72 | + /** |
| 73 | + * Empty stub. Leave it here or you will die a slow and painful death. |
| 74 | + * |
| 75 | + * @param targetVersion |
| 76 | + */ |
| 77 | + public static void checkVersionFormat(String targetVersion) {} |
| 78 | + |
| 79 | + /** |
| 80 | + * Empty stub. Leave it here or you will die a slow and painful death. |
| 81 | + * |
| 82 | + * @param resource |
| 83 | + * @param targetVersion |
| 84 | + */ |
| 85 | + public static void checkJavaVersion(String resource, String targetVersion) {} |
| 86 | +} |
0 commit comments