Skip to content

Commit

Permalink
OMID-171 Fix checkstyle warnings of common module
Browse files Browse the repository at this point in the history
  • Loading branch information
chia7712 committed Nov 13, 2020
1 parent 79c2a4a commit 731635e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
18 changes: 10 additions & 8 deletions common/src/main/java/org/apache/omid/NetworkUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.omid;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Collections;
import java.util.Enumeration;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class NetworkUtils {

private static final Logger LOG = LoggerFactory.getLogger(NetworkUtils.class);
Expand All @@ -36,7 +37,7 @@ public class NetworkUtils {

public static String getDefaultNetworkInterface() {

try (DatagramSocket s=new DatagramSocket()) {
try (DatagramSocket s = new DatagramSocket()) {
s.connect(InetAddress.getByAddress(new byte[]{1,1,1,1}), 0);
return NetworkInterface.getByInetAddress(s.getLocalAddress()).getName();
} catch (Exception e) {
Expand All @@ -51,13 +52,14 @@ public static String getDefaultNetworkInterface() {
NetworkInterface nextElement = networkInterfaces.nextElement();
String name = nextElement.getDisplayName();
LOG.info("Iterating over network interfaces, found '{}'", name);
boolean hasInet = Collections.list(nextElement.getInetAddresses()).size() > 1; // Checking that inet exists, to avoid taking iBridge
// Checking that inet exists, to avoid taking iBridge
boolean hasInet = Collections.list(nextElement.getInetAddresses()).size() > 1;
if (hasInet && fallBackName == null) {
fallBackName = name;
}
if ((name.startsWith(MAC_TSO_NET_IFACE_PREFIX) && hasInet ) ||
name.startsWith(LINUX_TSO_NET_IFACE_PREFIX)) {
return name;
if ((name.startsWith(MAC_TSO_NET_IFACE_PREFIX) && hasInet )
|| name.startsWith(LINUX_TSO_NET_IFACE_PREFIX)) {
return name;
}
}
if (fallBackName != null) {
Expand Down
3 changes: 2 additions & 1 deletion common/src/main/java/org/apache/omid/ReflectionHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.omid;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ReflectionHelper {

static public <T> Object invokeParameterlessMethod(T theObject, String methodName)
public static <T> Object invokeParameterlessMethod(T theObject, String methodName)
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {

Method method = theObject.getClass().getDeclaredMethod(methodName, null);
Expand Down
6 changes: 4 additions & 2 deletions common/src/main/java/org/apache/omid/YAMLUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.omid;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.phoenix.thirdparty.com.google.common.base.Preconditions;
import org.apache.phoenix.thirdparty.com.google.common.io.Resources;
import org.apache.commons.beanutils.BeanUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.Yaml;
Expand Down Expand Up @@ -56,7 +57,8 @@ public void loadSettings(String resourcePath, Object bean) {
@SuppressWarnings("unchecked")
public Map loadSettings(String resourcePath, String defaultResourcePath) throws IOException {
Map defaultSetting = loadAsMap(defaultResourcePath);
Preconditions.checkState(defaultSetting.size() > 0, String.format("Failed to load file '%s' from classpath", defaultResourcePath));
Preconditions.checkState(defaultSetting.size() > 0,
String.format("Failed to load file '%s' from classpath", defaultResourcePath));
if (resourcePath != null) {
Map userSetting = loadAsMap(resourcePath);
defaultSetting.putAll(userSetting);
Expand Down
1 change: 1 addition & 0 deletions common/src/main/java/org/apache/omid/zk/ZKUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.omid.zk;

import org.apache.curator.RetryPolicy;
Expand Down

0 comments on commit 731635e

Please sign in to comment.