-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CALCITE-5748] Upgrade guava from 31.1-jre to 32.0.0-jre #3240
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d797d8c
Upgrade guava from 31.1-jre to 32.0.0-jre
snuyanzin 070700f
Remove 2 guava based deprecated methods since they started to fail on…
snuyanzin b211cf8
Make redis tests passing on windows with guava 32
snuyanzin ed53df1
Make redis tests passing on windows with guava 32
snuyanzin 2d91a22
[CALCITE-5748] Make redis tests passing on windows with guava 32
snuyanzin ef1cb2d
[CALCITE-5748] Make redis tests passing on windows with guava 32
snuyanzin 29fdc13
[CALCITE-5748] Make redis tests passing on windows with guava 32
snuyanzin 4bbe93a
[CALCITE-5748] Make redis tests passing on windows with guava 32
snuyanzin 4ee57a0
[CALCITE-5748] Make redis tests passing on windows with guava 32
snuyanzin 5c69fd6
[CALCITE-5748] Make redis tests passing on windows with guava 32
snuyanzin 4bb95d0
[CALCITE-5748] Make redis tests passing on windows with guava 32
snuyanzin 899286d
[CALCITE-5748] Make redis tests passing on windows with guava 32
snuyanzin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
redis/src/test/java/org/apache/calcite/adapter/redis/CalciteTestRedisExecProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* 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. | ||
*/ | ||
package org.apache.calcite.adapter.redis; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
|
||
import com.google.common.io.Resources; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
import redis.embedded.util.Architecture; | ||
import redis.embedded.util.OS; | ||
import redis.embedded.util.OsArchitecture; | ||
|
||
/** | ||
* This is almost a copy of {@link redis.embedded.RedisExecProvider} invoking | ||
* {@link redis.embedded.util.JarUtil} under the hood. | ||
* The problem is that it calls deprecated guava's {@link com.google.common.io.Files#createTempDir()} | ||
* resulting in ''posix:permissions' not supported as initial attribute' on Windows. | ||
*/ | ||
public class CalciteTestRedisExecProvider { | ||
private final Map<OsArchitecture, String> executables = new HashMap<>(); | ||
|
||
public static CalciteTestRedisExecProvider defaultProvider() { | ||
return new CalciteTestRedisExecProvider(); | ||
} | ||
|
||
private CalciteTestRedisExecProvider() { | ||
initExecutables(); | ||
} | ||
|
||
private void initExecutables() { | ||
executables.put(OsArchitecture.WINDOWS_x86, "redis-server-2.8.19.exe"); | ||
executables.put(OsArchitecture.WINDOWS_x86_64, "redis-server-2.8.19.exe"); | ||
|
||
executables.put(OsArchitecture.UNIX_x86, "redis-server-2.8.19"); | ||
executables.put(OsArchitecture.UNIX_x86_64, "redis-server-2.8.19"); | ||
|
||
executables.put(OsArchitecture.MAC_OS_X_x86, "redis-server-2.8.19.app"); | ||
executables.put(OsArchitecture.MAC_OS_X_x86_64, "redis-server-2.8.19.app"); | ||
} | ||
|
||
public CalciteTestRedisExecProvider override(OS os, String executable) { | ||
Objects.requireNonNull(executable, "executable"); | ||
for (Architecture arch : Architecture.values()) { | ||
override(os, arch, executable); | ||
} | ||
return this; | ||
} | ||
|
||
public CalciteTestRedisExecProvider override(OS os, Architecture arch, String executable) { | ||
Objects.requireNonNull(executable, "executable"); | ||
executables.put(new OsArchitecture(os, arch), executable); | ||
return this; | ||
} | ||
|
||
public File get() throws IOException { | ||
OsArchitecture osArch = OsArchitecture.detect(); | ||
String executablePath = executables.get(osArch); | ||
return fileExists(executablePath) | ||
? new File(executablePath) | ||
: JarUtil.extractExecutableFromJar(executablePath); | ||
} | ||
|
||
private boolean fileExists(String executablePath) { | ||
return new File(executablePath).exists(); | ||
} | ||
|
||
/** | ||
* Calcite version of {@link redis.embedded.util.JarUtil} | ||
* allowing to make it work on Windows with Guava 32.0.0+. | ||
*/ | ||
private static class JarUtil { | ||
public static File extractExecutableFromJar(String executable) throws IOException { | ||
Path tmpDir = Files.createTempDirectory("redis"); | ||
|
||
File command = tmpDir.resolve(executable).toFile(); | ||
FileUtils.copyURLToFile(Resources.getResource(executable), command); | ||
command.deleteOnExit(); | ||
command.setExecutable(true); | ||
|
||
return command; | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
redis/src/test/java/org/apache/calcite/adapter/redis/CalciteTestRedisServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* 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. | ||
*/ | ||
package org.apache.calcite.adapter.redis; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import redis.embedded.RedisServer; | ||
import redis.embedded.RedisServerBuilder; | ||
|
||
/** | ||
* This is almost a copy of {@link RedisServer}. | ||
* The difference is that it makes {@link CalciteTestRedisServer#CalciteTestRedisServer(List, int)} | ||
* public, adds {@link CalciteTestRedisServer#testBuilder()}. | ||
*/ | ||
public class CalciteTestRedisServer extends RedisServer { | ||
private static CalciteTestRedisExecProvider redisExecProvider = | ||
CalciteTestRedisExecProvider.defaultProvider(); | ||
|
||
public CalciteTestRedisServer(File executable, Integer port) { | ||
super(executable, port); | ||
} | ||
|
||
public CalciteTestRedisServer(List<String> args, int port) throws IOException { | ||
super(redisExecProvider.get(), port); | ||
this.args = new ArrayList<>(args); | ||
} | ||
|
||
public static CalciteTestRedisServerBuilder testBuilder() { | ||
return new CalciteTestRedisServerBuilder(); | ||
} | ||
|
||
public static RedisServerBuilder builder() { | ||
throw new RuntimeException("Use CalciteTestRedisServer#testBuilder"); | ||
} | ||
} |
159 changes: 159 additions & 0 deletions
159
redis/src/test/java/org/apache/calcite/adapter/redis/CalciteTestRedisServerBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
/* | ||
* 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. | ||
*/ | ||
package org.apache.calcite.adapter.redis; | ||
|
||
import com.google.common.base.Strings; | ||
import com.google.common.io.Files; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.InetSocketAddress; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import redis.embedded.RedisServerBuilder; | ||
import redis.embedded.exceptions.RedisBuildingException; | ||
|
||
/** | ||
* This is almost a copy of {@link RedisServerBuilder}. | ||
* The difference is that it works with {@link CalciteTestRedisExecProvider}. | ||
*/ | ||
public class CalciteTestRedisServerBuilder { | ||
private static final String LINE_SEPARATOR = System.getProperty("line.separator"); | ||
private static final String CONF_FILENAME = "embedded-redis-server"; | ||
|
||
private File executable; | ||
private CalciteTestRedisExecProvider redisExecProvider = | ||
CalciteTestRedisExecProvider.defaultProvider(); | ||
private Integer port = 6379; | ||
private InetSocketAddress slaveOf; | ||
private String redisConf; | ||
|
||
private StringBuilder redisConfigBuilder; | ||
|
||
public CalciteTestRedisServerBuilder redisExecProvider( | ||
CalciteTestRedisExecProvider redisExecProvider) { | ||
this.redisExecProvider = redisExecProvider; | ||
return this; | ||
} | ||
|
||
public CalciteTestRedisServerBuilder port(Integer port) { | ||
this.port = port; | ||
return this; | ||
} | ||
|
||
public CalciteTestRedisServerBuilder slaveOf(String hostname, Integer port) { | ||
this.slaveOf = new InetSocketAddress(hostname, port); | ||
return this; | ||
} | ||
|
||
public CalciteTestRedisServerBuilder slaveOf(InetSocketAddress slaveOf) { | ||
this.slaveOf = slaveOf; | ||
return this; | ||
} | ||
|
||
public CalciteTestRedisServerBuilder configFile(String redisConf) { | ||
if (redisConfigBuilder != null) { | ||
throw new RedisBuildingException( | ||
"Redis configuration is already partially build using setting(String) method!"); | ||
} | ||
this.redisConf = redisConf; | ||
return this; | ||
} | ||
|
||
public CalciteTestRedisServerBuilder setting(String configLine) { | ||
if (redisConf != null) { | ||
throw new RedisBuildingException("Redis configuration is already set using redis conf file!"); | ||
} | ||
|
||
if (redisConfigBuilder == null) { | ||
redisConfigBuilder = new StringBuilder(); | ||
} | ||
|
||
redisConfigBuilder.append(configLine); | ||
redisConfigBuilder.append(LINE_SEPARATOR); | ||
return this; | ||
} | ||
|
||
public CalciteTestRedisServer build() { | ||
tryResolveConfAndExec(); | ||
List<String> args = buildCommandArgs(); | ||
try { | ||
return new CalciteTestRedisServer(args, port); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public void reset() { | ||
this.executable = null; | ||
this.redisConfigBuilder = null; | ||
this.slaveOf = null; | ||
this.redisConf = null; | ||
} | ||
|
||
private void tryResolveConfAndExec() { | ||
try { | ||
resolveConfAndExec(); | ||
} catch (IOException e) { | ||
throw new RedisBuildingException("Could not build server instance", e); | ||
} | ||
} | ||
|
||
private void resolveConfAndExec() throws IOException { | ||
if (redisConf == null && redisConfigBuilder != null) { | ||
File redisConfigFile = File.createTempFile(resolveConfigName(), ".conf"); | ||
redisConfigFile.deleteOnExit(); | ||
Files.asCharSink(redisConfigFile, StandardCharsets.UTF_8) | ||
.write(redisConfigBuilder.toString()); | ||
redisConf = redisConfigFile.getAbsolutePath(); | ||
} | ||
|
||
try { | ||
executable = redisExecProvider.get(); | ||
} catch (Exception e) { | ||
throw new RedisBuildingException("Failed to resolve executable", e); | ||
} | ||
} | ||
|
||
private String resolveConfigName() { | ||
return CONF_FILENAME + "_" + port; | ||
} | ||
|
||
private List<String> buildCommandArgs() { | ||
List<String> args = new ArrayList<String>(); | ||
args.add(executable.getAbsolutePath()); | ||
|
||
if (!Strings.isNullOrEmpty(redisConf)) { | ||
args.add(redisConf); | ||
} | ||
|
||
if (port != null) { | ||
args.add("--port"); | ||
args.add(Integer.toString(port)); | ||
} | ||
|
||
if (slaveOf != null) { | ||
args.add("--slaveof"); | ||
args.add(slaveOf.getHostName()); | ||
args.add(Integer.toString(slaveOf.getPort())); | ||
} | ||
|
||
return args; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With guava 32 it starts failing on errorprone checks with
CheckReturnValue
Since it is already deprecated with a comment what to use instead probably it makes sense to remove it