[JAVA-3615] Updating from 3.11.X to 3.12.X breaks Created: 01/Feb/20  Updated: 25/Aug/23  Resolved: 03/Feb/20

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: 3.12.0, 3.12.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Lingchao Chen Assignee: Jeffrey Yemin
Resolution: Declined Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: XML File mongodb-config.xml     XML File spring-mvc-servlet.xml    

 Description   

When I try to upgradeĀ mongo-java-driver from 3.11.X to 3.12.X. The following code breaks.

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:spring-mvc-servlet.xml")
public class DatabaseTest {
 
	@Autowired
	private IPersonService personService;
	
	@Test
	public void testConnection() {
		try {
			personService.findById("1");
		} catch (Exception e) {
			System.out.println("!!!!!!!!");
			fail("Database connection failed!");
		}
	}
}

public interface IPersonService {
 
	Person findById(String id);
}

public class Person {
    private String id;
}

The test should pass, but it failed with the error "Database connection failed!"
The related configuration files are in the attachment.



 Comments   
Comment by Lingchao Chen [ 03/Feb/20 ]

Yes. It's anĀ assertion failure. But the root cause behind it is cannot connect to the MongoDB through the driver.

Comment by Jeffrey Yemin [ 03/Feb/20 ]

Hi xia0c512@gmail.com

That's an assertion failure from your unit test, not an exception thrown from the driver.

I'm going to close this, as there is not enough information for us to pursue it. If you can get a stack trace from the driver we can re-open.

Comment by Lingchao Chen [ 03/Feb/20 ]

Hi @Jeffrey Yemin, thanks for your help. Here is the full stack trace:

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.595 sec <<< FAILURE!
testConnection(com.finartz.dao.DatabaseTest)  Time elapsed: 0.026 sec  <<< FAILURE!
java.lang.AssertionError: Database connection failed!
	at org.junit.Assert.fail(Assert.java:88)
	at com.finartz.dao.DatabaseTest.testConnection(DatabaseTest.java:25)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:73)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:73)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:224)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:83)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:68)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:163)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
 
[Thread-1] INFO org.springframework.context.support.GenericApplicationContext - Closing org.springframework.context.support.GenericApplicationContext@57baeedf: startup date [Mon Feb 03 09:26:06 CST 2020]; root of context hierarchy
 
Results :
 
Failed tests:   testConnection(com.finartz.dao.DatabaseTest): Database connection failed!
 
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

Comment by Jeffrey Yemin [ 03/Feb/20 ]

Hi xia0c512@gmail.com

Please provide the full stack trace of the exception that you're seeing with 3.12.

Generated at Thu Feb 08 09:00:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.