Kevin Findlay created GORA-428:
----------------------------------
Summary: Null pointer exception caused by incorrect handling of
gora.mongodb.login values that don't validate
Key: GORA-428
URL: https://issues.apache.org/jira/browse/GORA-428
Project: Apache Gora
Issue Type: Bug
Components: gora-mongodb
Affects Versions: 0.5
Environment: Ubuntu, Nutch2
Reporter: Kevin Findlay
Priority: Minor
A null pointer exception occurs when the gora.mongodb.login=nutch does not
validate.
Line 250 of the MongoStore class in method "private DB getDB(final String
servers, final String dbname, final String login, final String secret) throws
UnknownHostException" returns a null when the user is not validated.
if (login != null && secret != null) {
****PROBLEM**** auth = db.authenticate(login, secret.toCharArray());
}
This causes the method to return a null to :
mongoClientDB = getDB(vPropMongoServers, vPropMongoDb, vPropMongoLogin,
vPropMongoSecret);
In line 173 of MongoStore "public void initialize(final Class<K> keyClass,
final Class<T> pPersistentClass, final Properties properties)"
The code attempts to use this null value
*****PROBLEM****
as mongoClientColl = mongoClientDB
.getCollection(mapping.getCollectionName());
The solution is to check for a null point for mongoClientDB prior to use or,
better, write specific code to report when a login to MongoDB fails due to
authentication.
ERROR MESSAGE
InjectorJob: org.apache.gora.util.GoraException: java.lang.NullPointerException
at
org.apache.gora.store.DataStoreFactory.createDataStore(DataStoreFactory.java:169)
at
org.apache.gora.store.DataStoreFactory.createDataStore(DataStoreFactory.java:137)
at
org.apache.nutch.storage.StorageUtils.createWebStore(StorageUtils.java:78)
at org.apache.nutch.crawl.InjectorJob.run(InjectorJob.java:218)
at org.apache.nutch.crawl.InjectorJob.inject(InjectorJob.java:252)
at org.apache.nutch.crawl.InjectorJob.run(InjectorJob.java:275)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
at org.apache.nutch.crawl.InjectorJob.main(InjectorJob.java:284)
Caused by: java.lang.NullPointerException
at
org.apache.gora.mongodb.store.MongoStore.initialize(MongoStore.java:173)
at
org.apache.gora.store.DataStoreFactory.initializeDataStore(DataStoreFactory.java:104)
at
org.apache.gora.store.DataStoreFactory.createDataStore(DataStoreFactory.java:163)
... 7 more
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)