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

[systeminfo] Make getSwap* methods able to return 0 #7168

Merged
merged 2 commits into from Mar 15, 2020

Conversation

pacive
Copy link
Member

@pacive pacive commented Mar 14, 2020

Remove the null returns for getSwapTotal(), getSwapAvailable() and getSwapUsed(). This makes it obey the specifications in the SysteminfoInterface JavaDoc. Also changes getSwapAvailablePercent() and getSwapUsedPercent() to make variable naming more consistent.

Fixes #6983

When the getSwap* methods return null the channel and connected Item gets set to UNDEF. This fix makes it able to be set to 0 e.g. shortly after a system reboot, when no pages have been swapped yet.

Signed-off-by: Anders Alfredsson andersb86@gmail.com

Remove the null returns for getSwapTotal(), getSwapAvailable() and getSwapUsed(). This makes it obey the specifications in the SysteminfoInterface JavaDoc. Also changes getSwapAvailablePercent() and getSwapUsedPercent() to make variable naming more consistent.

Signed-off-by: Anders Alfredsson <andersb86@gmail.com>
@pacive pacive requested a review from svilenvul as a code owner March 14, 2020 18:07
@TravisBuddy
Copy link

Travis tests have failed

Hey @pacive,
please read the following log in order to understand the failure reason. There might also be some helpful tips along the way.
It will be awesome if you fix what is wrong and commit the changes.

1st Build

Expand here
Single addon pull request: Building org.openhab.binding.systeminfo
[WARNING] Could not find file feature file features/karaf/openhab-addons/src/main/feature/feature.xml
[WARNING] COMPILATION WARNING : 
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[139,5383] The method getVersion() from the type OperatingSystem is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[145,5534] The method getName() from the type CentralProcessor is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[151,5674] The method getModel() from the type CentralProcessor is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[152,5714] The method getFamily() from the type CentralProcessor is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[154,5823] The method getIdentifier() from the type CentralProcessor is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[155,5868] The method getVendor() from the type CentralProcessor is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[156,5915] The method isCpu64bit() from the type CentralProcessor is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[358,15260] The method getTimeRemaining() from the type PowerSource is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[370,16056] The method getRemainingCapacity() from the type PowerSource is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/discovery/SysteminfoDiscoveryService.java:[24,795] The import org.eclipse.smarthome.config.discovery.DiscoveryResult is never used
[ERROR] COMPILATION ERROR : 
[ERROR] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[431,18324] The default '@NonNull' conflicts with the inherited '@Nullable' annotation in the overridden method from SysteminfoInterface 
[ERROR] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[438,18539] The default '@NonNull' conflicts with the inherited '@Nullable' annotation in the overridden method from SysteminfoInterface 
[ERROR] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[447,18886] The default '@NonNull' conflicts with the inherited '@Nullable' annotation in the overridden method from SysteminfoInterface 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project org.openhab.binding.systeminfo: Compilation failure: Compilation failure: 
[ERROR] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[431,18324] The default '@NonNull' conflicts with the inherited '@Nullable' annotation in the overridden method from SysteminfoInterface 
[ERROR] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[438,18539] The default '@NonNull' conflicts with the inherited '@Nullable' annotation in the overridden method from SysteminfoInterface 
[ERROR] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[447,18886] The default '@NonNull' conflicts with the inherited '@Nullable' annotation in the overridden method from SysteminfoInterface
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :org.openhab.binding.systeminfo

### 2nd Build
Expand here
Single addon pull request: Building org.openhab.binding.systeminfo
[WARNING] The POM for com.sun.xml.bind:jaxb-core:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.sun.xml.bind:jaxb-impl:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] Could not find file feature file features/karaf/openhab-addons/src/main/feature/feature.xml
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/home/travis/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.11/jaxb-impl-2.2.11.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of com.sun.xml.bind.v2.runtime.reflect.opt.Injector
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[WARNING] COMPILATION WARNING : 
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[139,5383] The method getVersion() from the type OperatingSystem is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[145,5534] The method getName() from the type CentralProcessor is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[151,5674] The method getModel() from the type CentralProcessor is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[152,5714] The method getFamily() from the type CentralProcessor is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[154,5823] The method getIdentifier() from the type CentralProcessor is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[155,5868] The method getVendor() from the type CentralProcessor is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[156,5915] The method isCpu64bit() from the type CentralProcessor is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[334,13977] The method setScale(int, int) from the type BigDecimal is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[334,14027] The field BigDecimal.ROUND_HALF_UP is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[341,14299] The method setScale(int, int) from the type BigDecimal is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[341,14349] The field BigDecimal.ROUND_HALF_UP is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[358,15260] The method getTimeRemaining() from the type PowerSource is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[370,16056] The method getRemainingCapacity() from the type PowerSource is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[486,20441] The method setScale(int, int) from the type BigDecimal is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[486,20491] The field BigDecimal.ROUND_HALF_UP is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[492,20710] The method setScale(int, int) from the type BigDecimal is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[492,20760] The field BigDecimal.ROUND_UP is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[547,22376] The method setScale(int, int) from the type BigDecimal is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[547,22426] The field BigDecimal.ROUND_HALF_UP is deprecated
[WARNING] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/discovery/SysteminfoDiscoveryService.java:[24,795] The import org.eclipse.smarthome.config.discovery.DiscoveryResult is never used
[ERROR] COMPILATION ERROR : 
[ERROR] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[431,18324] The default '@NonNull' conflicts with the inherited '@Nullable' annotation in the overridden method from SysteminfoInterface 
[ERROR] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[438,18539] The default '@NonNull' conflicts with the inherited '@Nullable' annotation in the overridden method from SysteminfoInterface 
[ERROR] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[447,18886] The default '@NonNull' conflicts with the inherited '@Nullable' annotation in the overridden method from SysteminfoInterface 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project org.openhab.binding.systeminfo: Compilation failure: Compilation failure: 
[ERROR] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[431,18324] The default '@NonNull' conflicts with the inherited '@Nullable' annotation in the overridden method from SysteminfoInterface 
[ERROR] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[438,18539] The default '@NonNull' conflicts with the inherited '@Nullable' annotation in the overridden method from SysteminfoInterface 
[ERROR] /home/travis/build/openhab/openhab-addons/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java:[447,18886] The default '@NonNull' conflicts with the inherited '@Nullable' annotation in the overridden method from SysteminfoInterface
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :org.openhab.binding.systeminfo

Signed-off-by: Anders Alfredsson <andersb86@gmail.com>
@TravisBuddy
Copy link

Travis tests were successful

Hey @pacive,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

Copy link
Member

@wborn wborn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It makes a lot of sense that you can see all available swap got reduced to 0 or it was configured to 0.

@wborn wborn merged commit 8a0b18e into openhab:2.5.x Mar 15, 2020
@pacive pacive deleted the 6983-fix branch March 15, 2020 14:30
@pacive
Copy link
Member Author

pacive commented Mar 15, 2020

I might continue to make some small updates this binding in order to learn some more. I noticed that it uses some deprecated methods in OSHI that I could update (a lot of warnings when compiling). Should I open an issue for that first, or can I just make a new PR?

@wborn
Copy link
Member

wborn commented Mar 15, 2020

Fixing the deprecations would also be appreciated! You can submit PRs directly though creating issues for this is always helpful if you won't create the PR soon. It may prevent multiple PRs that solve the same issue if you also mention in the issue that you're working on it. So it may save yourself/others wasting their time causing frustration.

@kaikreuzer kaikreuzer added the bug An unexpected problem or unintended behavior of an add-on label Mar 18, 2020
@kaikreuzer kaikreuzer added this to the 2.5.3 milestone Mar 18, 2020
leluna pushed a commit to leluna/openhab2-addons that referenced this pull request Mar 21, 2020
Make getSwap* methods able to return 0

Remove the null returns for getSwapTotal(), getSwapAvailable() and getSwapUsed(). This makes it obey the specifications in the SysteminfoInterface JavaDoc. Also changes getSwapAvailablePercent() and getSwapUsedPercent() to make variable naming more consistent.

Signed-off-by: Anders Alfredsson <andersb86@gmail.com>
Signed-off-by: leluna <hengrui.jiang@googlemail.com>
Hans-Reiner pushed a commit to Hans-Reiner/openhab2-addons that referenced this pull request Apr 11, 2020
Make getSwap* methods able to return 0

Remove the null returns for getSwapTotal(), getSwapAvailable() and getSwapUsed(). This makes it obey the specifications in the SysteminfoInterface JavaDoc. Also changes getSwapAvailablePercent() and getSwapUsedPercent() to make variable naming more consistent.

Signed-off-by: Anders Alfredsson <andersb86@gmail.com>
Signed-off-by: Hans-Reiner Hoffmann <hans-reiner.hoffmann@gmx.de>
markus7017 pushed a commit to markus7017/openhab-addons that referenced this pull request May 29, 2020
Make getSwap* methods able to return 0

Remove the null returns for getSwapTotal(), getSwapAvailable() and getSwapUsed(). This makes it obey the specifications in the SysteminfoInterface JavaDoc. Also changes getSwapAvailablePercent() and getSwapUsedPercent() to make variable naming more consistent.

Signed-off-by: Anders Alfredsson <andersb86@gmail.com>
LoungeFlyZ pushed a commit to LoungeFlyZ/openhab2-addons that referenced this pull request Jun 8, 2020
Make getSwap* methods able to return 0

Remove the null returns for getSwapTotal(), getSwapAvailable() and getSwapUsed(). This makes it obey the specifications in the SysteminfoInterface JavaDoc. Also changes getSwapAvailablePercent() and getSwapUsedPercent() to make variable naming more consistent.

Signed-off-by: Anders Alfredsson <andersb86@gmail.com>
J-N-K pushed a commit to J-N-K/openhab-addons that referenced this pull request Jul 14, 2020
Make getSwap* methods able to return 0

Remove the null returns for getSwapTotal(), getSwapAvailable() and getSwapUsed(). This makes it obey the specifications in the SysteminfoInterface JavaDoc. Also changes getSwapAvailablePercent() and getSwapUsedPercent() to make variable naming more consistent.

Signed-off-by: Anders Alfredsson <andersb86@gmail.com>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
Make getSwap* methods able to return 0

Remove the null returns for getSwapTotal(), getSwapAvailable() and getSwapUsed(). This makes it obey the specifications in the SysteminfoInterface JavaDoc. Also changes getSwapAvailablePercent() and getSwapUsedPercent() to make variable naming more consistent.

Signed-off-by: Anders Alfredsson <andersb86@gmail.com>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
Make getSwap* methods able to return 0

Remove the null returns for getSwapTotal(), getSwapAvailable() and getSwapUsed(). This makes it obey the specifications in the SysteminfoInterface JavaDoc. Also changes getSwapAvailablePercent() and getSwapUsedPercent() to make variable naming more consistent.

Signed-off-by: Anders Alfredsson <andersb86@gmail.com>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
Make getSwap* methods able to return 0

Remove the null returns for getSwapTotal(), getSwapAvailable() and getSwapUsed(). This makes it obey the specifications in the SysteminfoInterface JavaDoc. Also changes getSwapAvailablePercent() and getSwapUsedPercent() to make variable naming more consistent.

Signed-off-by: Anders Alfredsson <andersb86@gmail.com>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
Make getSwap* methods able to return 0

Remove the null returns for getSwapTotal(), getSwapAvailable() and getSwapUsed(). This makes it obey the specifications in the SysteminfoInterface JavaDoc. Also changes getSwapAvailablePercent() and getSwapUsedPercent() to make variable naming more consistent.

Signed-off-by: Anders Alfredsson <andersb86@gmail.com>
DaanMeijer pushed a commit to DaanMeijer/openhab-addons that referenced this pull request Sep 1, 2020
Make getSwap* methods able to return 0

Remove the null returns for getSwapTotal(), getSwapAvailable() and getSwapUsed(). This makes it obey the specifications in the SysteminfoInterface JavaDoc. Also changes getSwapAvailablePercent() and getSwapUsedPercent() to make variable naming more consistent.

Signed-off-by: Anders Alfredsson <andersb86@gmail.com>
Signed-off-by: Daan Meijer <daan@studioseptember.nl>
markus7017 pushed a commit to markus7017/openhab-addons that referenced this pull request Sep 19, 2020
Make getSwap* methods able to return 0

Remove the null returns for getSwapTotal(), getSwapAvailable() and getSwapUsed(). This makes it obey the specifications in the SysteminfoInterface JavaDoc. Also changes getSwapAvailablePercent() and getSwapUsedPercent() to make variable naming more consistent.

Signed-off-by: Anders Alfredsson <andersb86@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[systeminfo] swap#used set to UNDEF when 0
4 participants