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

HHH-18770 NPE when using the JFR integration with JFR disabled #9182

Merged
merged 3 commits into from
Nov 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
HHH-18770 test with the jfr module on the classpath but jfr disabled
gtoison authored and dreab8 committed Oct 29, 2024
commit 85ade3714757c0b59622fefce0847b18378f7fa9
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.event.jfr.flush;

import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Test;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;


@DomainModel(annotatedClasses = {
AutoFlushJfrDisabledTests.TestEntity.class,
})
@SessionFactory
@JiraKey(value = "HHH-18770")
public class AutoFlushJfrDisabledTests {

/**
* Execute a query (and a flush) with the jfr module on the classpath but jfr disabled
*/
@Test
public void testFlushEventWithPartialFlushEventDisabled(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
TestEntity entity = new TestEntity( 1, "name_1" );
session.persist( entity );
session.createQuery( "select t from TestEntity t" ).list();

session.remove( entity );
}
);
}

@Entity(name = "TestEntity")
public static class TestEntity {
@Id
private Integer id;

private String name;

public TestEntity() {
}

public TestEntity(Integer id, String name) {
this.id = id;
this.name = name;
}

public void setName(String name) {
this.name = name;
}
}

}