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

[BUG] SQL drivers are not relocated when using DatabaseLibrary#connectToORM #113

Open
A248 opened this issue Jul 30, 2023 · 6 comments
Open
Labels
bug Something isn't working

Comments

@A248
Copy link

A248 commented Jul 30, 2023

Describe the bug
LimboAuth relocates most of the libraries it uses (see build.gradle). However, JDBC drivers in the DatabaseLibrary enum are not relocated when they are downloaded. The driver classes should be remapped to the proper namespace, but they are not, which causes conflicts with other plugins.

This matters because the DatabaseLibrary#connectToORM method, used by LimboAuth, loads the dependency by attaching it to the plugin classloader. As a result, the driver classes become visible to other plugins. (This is a problem for the same reason that forgetting to relocate dependencies in the build.gradle is a problem)

Note that the DatabaseLibrary#connect method is okay, because it loads the driver in an isolated classloader. Using an isolated classloader is an accepted practice for loading an unrelocated dependency. However, LimboAuth doesn't use the connect method anymore; it uses connectToORM.

To Reproduce
You can observe conflicts between LimboAuth and other plugins which use the MariaDB driver. For example, LibertyBans is a plugin which uses an isolated classloader for its own copy of the MariaDB driver. This leads to classloading violations in LibertyBans because some of the MariaDB classes are mixed up with the (same) classes loaded by LimboAuth. Because the same classes are loaded by two separate classloaders, classloading errors result.

Steps to reproduce the behavior:

  1. Install LimboAuth and LibertyBans, for example
  2. Configure both plugins to use MariaDB
  3. Observe classloading violations in LibertyBans

See error: https://hastebin.bluetree242.dev/xeciqimeve.less

Expected behavior
LimboAuth relocates all of its dependencies which are not placed into an isolated classloader.

Screenshots
https://hastebin.bluetree242.dev/xeciqimeve.less

Server Info (please complete the following information):

  • All Limbo plugins versions:
  • LimboAuth 1.1.13
  • LimboAPI 1.1.13
  • LibertyBans 1.1.0-M3
  • /velocity dump

Additional context
You have a few options to solve the problem. You could relocate dependencies at runtime: other plugins use libraries to do this (however, if you use lucko's jar-relocator, make sure to depend on the latest version, because prior versions have bugs).

Another option would be to find a way to configure your ORM to use the isolated classloader. Then you could continue to use the connect method with an isolated classloader. For example, some libraries make use of the thread context classloader which instructs the ORM where to search for the driver. You'll have to consult your ORM documentation on this.

@A248 A248 added the bug Something isn't working label Jul 30, 2023
@mdxd44
Copy link
Member

mdxd44 commented Jul 30, 2023

Error logs already inacessible, please use pastebin and Paste Expiration: Never

@A248
Copy link
Author

A248 commented Jul 30, 2023

Pardon me. The error logs are irrelevant, because the bug is a matter of contract observation.

Anyway, here are your error logs: https://pastebin.com/n05Y1P8F

@mdxd44
Copy link
Member

mdxd44 commented Jul 30, 2023

and this error doesn't appears without limboauth?

@A248
Copy link
Author

A248 commented Jul 31, 2023

No, it doesn't.

@MeteoraCD2
Copy link

MeteoraCD2 commented Dec 21, 2023

Я столкнулся с этой же проблемой: LibertyBans сыпет ошибками, если загрузить limboAuth. Без LimboAuth ни единой ошибки.
https://pastebin.com/4K2HwEZV

@mdxd44
Copy link
Member

mdxd44 commented Dec 21, 2023

Beginning from new 2.0.0 version this issue should be fixed, please wait untill it will be released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants