HADOOP-16299. [JDK 11] Build fails without specifying -Djavac.version=11
Signed-off-by: Takanobu Asanuma <tasanuma@apache.org>
This commit is contained in:
parent
0c5fa2e7d9
commit
f257497b0f
@ -46,7 +46,6 @@
|
|||||||
import javax.naming.spi.InitialContextFactory;
|
import javax.naming.spi.InitialContextFactory;
|
||||||
|
|
||||||
import com.google.common.collect.Iterators;
|
import com.google.common.collect.Iterators;
|
||||||
import com.sun.jndi.ldap.LdapCtxFactory;
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.classification.InterfaceStability;
|
import org.apache.hadoop.classification.InterfaceStability;
|
||||||
import org.apache.hadoop.conf.Configurable;
|
import org.apache.hadoop.conf.Configurable;
|
||||||
@ -270,8 +269,9 @@ public class LdapGroupsMapping
|
|||||||
|
|
||||||
public static final String LDAP_CTX_FACTORY_CLASS_KEY =
|
public static final String LDAP_CTX_FACTORY_CLASS_KEY =
|
||||||
LDAP_CONFIG_PREFIX + ".ctx.factory.class";
|
LDAP_CONFIG_PREFIX + ".ctx.factory.class";
|
||||||
public static final Class<? extends LdapCtxFactory>
|
|
||||||
LDAP_CTX_FACTORY_CLASS_DEFAULT = LdapCtxFactory.class;
|
public static final String LDAP_CTX_FACTORY_CLASS_DEFAULT =
|
||||||
|
"com.sun.jndi.ldap.LdapCtxFactory";
|
||||||
|
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
LoggerFactory.getLogger(LdapGroupsMapping.class);
|
LoggerFactory.getLogger(LdapGroupsMapping.class);
|
||||||
@ -314,7 +314,7 @@ public class LdapGroupsMapping
|
|||||||
private boolean useOneQuery;
|
private boolean useOneQuery;
|
||||||
private int numAttempts;
|
private int numAttempts;
|
||||||
private int numAttemptsBeforeFailover;
|
private int numAttemptsBeforeFailover;
|
||||||
private Class<? extends InitialContextFactory> ldapCxtFactoryClass;
|
private String ldapCtxFactoryClassName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of groups for a user.
|
* Returns list of groups for a user.
|
||||||
@ -633,7 +633,7 @@ private DirContext getDirContext() throws NamingException {
|
|||||||
if (ctx == null) {
|
if (ctx == null) {
|
||||||
// Set up the initial environment for LDAP connectivity
|
// Set up the initial environment for LDAP connectivity
|
||||||
Hashtable<String, String> env = new Hashtable<>();
|
Hashtable<String, String> env = new Hashtable<>();
|
||||||
env.put(Context.INITIAL_CONTEXT_FACTORY, ldapCxtFactoryClass.getName());
|
env.put(Context.INITIAL_CONTEXT_FACTORY, ldapCtxFactoryClassName);
|
||||||
env.put(Context.PROVIDER_URL, currentLdapUrl);
|
env.put(Context.PROVIDER_URL, currentLdapUrl);
|
||||||
env.put(Context.SECURITY_AUTHENTICATION, "simple");
|
env.put(Context.SECURITY_AUTHENTICATION, "simple");
|
||||||
|
|
||||||
@ -755,8 +755,18 @@ public synchronized void setConf(Configuration conf) {
|
|||||||
}
|
}
|
||||||
SEARCH_CONTROLS.setReturningAttributes(returningAttributes);
|
SEARCH_CONTROLS.setReturningAttributes(returningAttributes);
|
||||||
|
|
||||||
ldapCxtFactoryClass = conf.getClass(LDAP_CTX_FACTORY_CLASS_KEY,
|
// LDAP_CTX_FACTORY_CLASS_DEFAULT is not open to unnamed modules
|
||||||
LDAP_CTX_FACTORY_CLASS_DEFAULT, InitialContextFactory.class);
|
// in Java 11+, so the default value is set to null to avoid
|
||||||
|
// creating the instance for now.
|
||||||
|
Class<? extends InitialContextFactory> ldapCtxFactoryClass =
|
||||||
|
conf.getClass(LDAP_CTX_FACTORY_CLASS_KEY, null,
|
||||||
|
InitialContextFactory.class);
|
||||||
|
if (ldapCtxFactoryClass != null) {
|
||||||
|
ldapCtxFactoryClassName = ldapCtxFactoryClass.getName();
|
||||||
|
} else {
|
||||||
|
// The default value is set afterwards.
|
||||||
|
ldapCtxFactoryClassName = LDAP_CTX_FACTORY_CLASS_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
this.numAttempts = conf.getInt(LDAP_NUM_ATTEMPTS_KEY,
|
this.numAttempts = conf.getInt(LDAP_NUM_ATTEMPTS_KEY,
|
||||||
LDAP_NUM_ATTEMPTS_DEFAULT);
|
LDAP_NUM_ATTEMPTS_DEFAULT);
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
import static org.apache.hadoop.security.LdapGroupsMapping.LDAP_CTX_FACTORY_CLASS_KEY;
|
import static org.apache.hadoop.security.LdapGroupsMapping.LDAP_CTX_FACTORY_CLASS_KEY;
|
||||||
import static org.apache.hadoop.security.LdapGroupsMapping.LDAP_URL_KEY;
|
import static org.apache.hadoop.security.LdapGroupsMapping.LDAP_URL_KEY;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@ -36,6 +35,7 @@
|
|||||||
import javax.naming.directory.DirContext;
|
import javax.naming.directory.DirContext;
|
||||||
import javax.naming.directory.SearchControls;
|
import javax.naming.directory.SearchControls;
|
||||||
import javax.naming.directory.SearchResult;
|
import javax.naming.directory.SearchResult;
|
||||||
|
import javax.naming.ldap.InitialLdapContext;
|
||||||
import javax.naming.spi.InitialContextFactory;
|
import javax.naming.spi.InitialContextFactory;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
@ -235,13 +235,10 @@ public Context getInitialContext(Hashtable<?, ?> env)
|
|||||||
assertEquals(expectedBindPassword, actualBindPassword);
|
assertEquals(expectedBindPassword, actualBindPassword);
|
||||||
}
|
}
|
||||||
if (contextToReturn == null) {
|
if (contextToReturn == null) {
|
||||||
InitialContextFactory defaultFactory = null;
|
Hashtable<Object, Object> newEnv = new Hashtable<>(env);
|
||||||
try {
|
newEnv.put(Context.INITIAL_CONTEXT_FACTORY,
|
||||||
defaultFactory = LDAP_CTX_FACTORY_CLASS_DEFAULT.newInstance();
|
LDAP_CTX_FACTORY_CLASS_DEFAULT);
|
||||||
} catch (ReflectiveOperationException e) {
|
contextToReturn = new InitialLdapContext(newEnv, null);
|
||||||
fail("Could not initialize the default factory");
|
|
||||||
}
|
|
||||||
return defaultFactory.getInitialContext(env);
|
|
||||||
}
|
}
|
||||||
return contextToReturn;
|
return contextToReturn;
|
||||||
}
|
}
|
||||||
|
@ -2070,21 +2070,9 @@
|
|||||||
<additionalOptions>
|
<additionalOptions>
|
||||||
<!-- TODO: remove -html4 option to generate html5 docs when we stop supporting JDK8 -->
|
<!-- TODO: remove -html4 option to generate html5 docs when we stop supporting JDK8 -->
|
||||||
<additionalOption>-html4</additionalOption>
|
<additionalOption>-html4</additionalOption>
|
||||||
<additionalOption>--add-exports</additionalOption>
|
|
||||||
<additionalOption>java.naming/com.sun.jndi.ldap=ALL-UNNAMED</additionalOption>
|
|
||||||
</additionalOptions>
|
</additionalOptions>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<compilerArgs combine.children="append">
|
|
||||||
<arg>--add-exports</arg>
|
|
||||||
<arg>java.naming/com.sun.jndi.ldap=ALL-UNNAMED</arg>
|
|
||||||
</compilerArgs>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
|
Loading…
Reference in New Issue
Block a user