Skip to content
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

Incorrect code snippet for change streams documentation #4376

Closed
sergey-morenets opened this issue Apr 26, 2023 · 1 comment
Closed

Incorrect code snippet for change streams documentation #4376

sergey-morenets opened this issue Apr 26, 2023 · 1 comment
Labels
type: documentation A documentation update

Comments

@sergey-morenets
Copy link

Hi

Here's code snippet from official documentation(https://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#change-streams):


MessageListenerContainer container = new DefaultMessageListenerContainer(template);
container.start();                                                                                        

MessageListener<ChangeStreamDocument<Document>, User> listener = System.out::println;                     
ChangeStreamRequestOptions options = **new ChangeStreamRequestOptions("user", ChangeStreamOptions.empty());**

However current Spring Data MongoDB version (4.0.5) doesn't contain ChangeStreamRequestOptions class where constructor accepts two parameters, only three arguments:

		public ChangeStreamRequestOptions(@Nullable String databaseName, @Nullable String collectionName,
				ChangeStreamOptions options) {
			this(databaseName, collectionName, null, options);
		}

public ChangeStreamRequestOptions(@Nullable String databaseName, @Nullable String collectionName,
				@Nullable Duration maxAwaitTime, ChangeStreamOptions options) {

			Assert.notNull(options, "Options must not be null");

			this.collectionName = collectionName;
			this.databaseName = databaseName;
			this.maxAwaitTime = maxAwaitTime;
			this.options = options;
		}

The code snippet below doesn't compile:

Subscription subscription = container.register(new ChangeStreamRequest<>(listener, options), User.class);

with error:

Cannot infer type arguments for ChangeStreamRequest<>

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 26, 2023
@christophstrobl christophstrobl added type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 27, 2023
@christophstrobl
Copy link
Member

@sergey-morenets thanks for the heads up, we'll update the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

3 participants