首页 文章 精选 留言 我的

精选列表

搜索[Bug修复],共10000篇文章
优秀的个人博客,低调大师

Kotlin项目类找不到bug:java.lang.ClassNotFoundException: kotlin.reflect.Kotli...

一、今天在创建了一个Kotlin+Spring的项目,结果启动报错 org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at net.AppKt.main(App.kt:26) [classes/:na] Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:126) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:86) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:409) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:174) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:179) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:152) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] ... 8 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'httpPutFormContentFilter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter]: Factory method 'httpPutFormContentFilter' threw exception; nested exception is java.lang.NoClassDefFoundError: kotlin/reflect/KotlinReflectionInternalError at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:587) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:541) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:225) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:181) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:176) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAdaptableBeans(ServletContextInitializerBeans.java:158) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:80) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans(ServletWebServerApplicationContext.java:250) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.selfInitialize(ServletWebServerApplicationContext.java:237) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.web.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:54) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5204) ~[tomcat-embed-core-8.5.29.jar:8.5.29] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.29.jar:8.5.29] at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421) ~[tomcat-embed-core-8.5.29.jar:8.5.29] at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411) ~[tomcat-embed-core-8.5.29.jar:8.5.29] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_161] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_161] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_161] at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_161] Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter]: Factory method 'httpPutFormContentFilter' threw exception; nested exception is java.lang.NoClassDefFoundError: kotlin/reflect/KotlinReflectionInternalError at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] ... 24 common frames omitted Caused by: java.lang.NoClassDefFoundError: kotlin/reflect/KotlinReflectionInternalError at com.fasterxml.jackson.module.kotlin.KotlinModule.setupModule(KotlinModule.kt:44) ~[jackson-module-kotlin-2.8.4.jar:2.8.4] at com.fasterxml.jackson.databind.ObjectMapper.registerModule(ObjectMapper.java:751) ~[jackson-databind-2.9.5.jar:2.9.5] at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.registerWellKnownModulesIfAvailable(Jackson2ObjectMapperBuilder.java:766) ~[spring-web-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.configure(Jackson2ObjectMapperBuilder.java:624) ~[spring-web-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.build(Jackson2ObjectMapperBuilder.java:608) ~[spring-web-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.<init>(MappingJackson2HttpMessageConverter.java:59) ~[spring-web-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.<init>(AllEncompassingFormHttpMessageConverter.java:74) ~[spring-web-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.web.filter.HttpPutFormContentFilter.<init>(HttpPutFormContentFilter.java:64) ~[spring-web-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter.<init>(OrderedHttpPutFormContentFilter.java:29) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.httpPutFormContentFilter(WebMvcAutoConfiguration.java:163) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$$EnhancerBySpringCGLIB$$f2471238.CGLIB$httpPutFormContentFilter$1(<generated>) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$$EnhancerBySpringCGLIB$$f2471238$$FastClassBySpringCGLIB$$9f061c7c.invoke(<generated>) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$$EnhancerBySpringCGLIB$$f2471238.httpPutFormContentFilter(<generated>) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_161] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] ... 25 common frames omitted Caused by: java.lang.ClassNotFoundException: kotlin.reflect.KotlinReflectionInternalError at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_161] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_161] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_161] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_161] ... 45 common frames omitted 二、一看到这么多错误日志,很多同学直接懵了,其实有用的就在最后两个Caused By Caused by: java.lang.NoClassDefFoundError: kotlin/reflect/KotlinReflectionInternalError at com.fasterxml.jackson.module.kotlin.KotlinModule.setupModule(KotlinModule.kt:44) ~[jackson-module-kotlin-2.8.4.jar:2.8.4] at com.fasterxml.jackson.databind.ObjectMapper.registerModule(ObjectMapper.java:751) ~[jackson-databind-2.9.5.jar:2.9.5] at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.registerWellKnownModulesIfAvailable(Jackson2ObjectMapperBuilder.java:766) ~[spring-web-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.configure(Jackson2ObjectMapperBuilder.java:624) ~[spring-web-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.build(Jackson2ObjectMapperBuilder.java:608) ~[spring-web-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.<init>(MappingJackson2HttpMessageConverter.java:59) ~[spring-web-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.<init>(AllEncompassingFormHttpMessageConverter.java:74) ~[spring-web-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.web.filter.HttpPutFormContentFilter.<init>(HttpPutFormContentFilter.java:64) ~[spring-web-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter.<init>(OrderedHttpPutFormContentFilter.java:29) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.httpPutFormContentFilter(WebMvcAutoConfiguration.java:163) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$$EnhancerBySpringCGLIB$$f2471238.CGLIB$httpPutFormContentFilter$1(<generated>) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$$EnhancerBySpringCGLIB$$f2471238$$FastClassBySpringCGLIB$$9f061c7c.invoke(<generated>) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE] at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$$EnhancerBySpringCGLIB$$f2471238.httpPutFormContentFilter(<generated>) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_161] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] ... 25 common frames omitted Caused by: java.lang.ClassNotFoundException: kotlin.reflect.KotlinReflectionInternalError at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_161] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_161] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338) ~[na:1.8.0_161] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_161] ... 45 common frames omitted 三、下面我们来google搜一搜 java.lang.ClassNotFoundException: kotlin.reflect.Kotlin Reflect Internal Error 四、点击第一个看一看 这里写链接内容 这个高分哥们说,他升级了Kotlin版本和Jackson版本后就好了 五、那么我们也来更新一下 1.先来更新Kotlin的版本,1.2.30 2.再来搜搜,看看jackson-module-kotlin:版本更新到哪里了 以前配的是2.8.4,可能太老了 compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.8.4" maven仓库 3.将2.9版本的配上去 六、启动成功了,现在问题解决了 好啦,结束啦!

优秀的个人博客,低调大师

黑客也看《人民的名义》:把手机卡扔马桶有 bug

自从《人民的名义》的导演在接受媒体采访时表示,有点担心这部剧随时会断播时,雷锋网编辑就领会了这层意思:赶紧看,且看且珍惜。 果不其然,这部剧最近有点火。剧情是这样开始的: “一位国家部委的项目处长被人举报受贿千万,当最高人民检察院反贪总局侦查处处长侯亮平前来搜查时,看到的却是一位长相憨厚、衣着朴素的“老农民”在简陋破败的旧房里吃炸酱面。 当这位腐败分子的面具被最终撕开的同时,与之案件牵连甚紧的 H 省京州市副市长丁义珍,却在一位神秘人物的暗中相助下,以反侦察手段逃脱法网,流亡海外。案件线索终定位于由京州光明峰项目引发的一家H省国企大风服装厂的股权争夺,牵连其中的各派政治势力却盘根错节,扑朔迷离。” 在大家为展现的反腐尺度和紧张剧情欢欣鼓舞时,雷锋网编辑却发现了一些“不一样”的信息。尤其是,雷锋网发现,神秘人物将给丁义珍通风报信的手机卡

优秀的个人博客,低调大师

【我的Android进阶之旅】 解决bug: Expected file scheme in URI: content://download...

一、错误描述 今天测试MM用HTC手机测试某个模块的时候crash了,抓log后发现是使用DownloadManager下载apk安装包然后自动安装的时候,抛了异常:java.lang.IllegalArgumentException: Expected file scheme in URI: content://downloads/my_downloads/12 具体crash错误信息如下所示: 11-30 09:24:21.933 28279 28279 E AndroidRuntime: FATAL EXCEPTION: main 11-30 09:24:21.933 28279 28279 E AndroidRuntime: Process: com.xtc.watch, PID: 28279 11-30 09:24:21.933 28279 28279 E AndroidRuntime: java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.DOWNLOAD_COMPLETE flg=0x10 pkg=com.xtc.watch (has extras) } in com.xtc.watch.service.compatible.VersionCompatibleUpdateService$DownloadCompleteReceiver@33fa7ec 11-30 09:24:21.933 28279 28279 E AndroidRuntime: at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:934) 11-30 09:24:21.933 28279 28279 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739) 11-30 09:24:21.933 28279 28279 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95) 11-30 09:24:21.933 28279 28279 E AndroidRuntime: at android.os.Looper.loop(Looper.java:168) 11-30 09:24:21.933 28279 28279 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5885) 11-30 09:24:21.933 28279 28279 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 11-30 09:24:21.933 28279 28279 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797) 11-30 09:24:21.933 28279 28279 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687) 11-30 09:24:21.933 28279 28279 E AndroidRuntime: Caused by: java.lang.IllegalArgumentException: Expected file scheme in URI: content://downloads/my_downloads/12 11-30 09:24:21.933 28279 28279 E AndroidRuntime: at java.io.File.checkURI(File.java:223) 11-30 09:24:21.933 28279 28279 E AndroidRuntime: at java.io.File.<init>(File.java:175) 11-30 09:24:21.933 28279 28279 E AndroidRuntime: at com.xtc.watch.service.compatible.VersionCompatibleUpdateService.a(Unknown Source) 11-30 09:24:21.933 28279 28279 E AndroidRuntime: at com.xtc.watch.service.compatible.VersionCompatibleUpdateService.a(Unknown Source) 11-30 09:24:21.933 28279 28279 E AndroidRuntime: at com.xtc.watch.service.compatible.VersionCompatibleUpdateService$DownloadCompleteReceiver.onReceive(Unknown Source) 11-30 09:24:21.933 28279 28279 E AndroidRuntime: at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:915) 11-30 09:24:21.933 28279 28279 E AndroidRuntime: ... 7 more 11-30 09:24:21.939 1785 3503 E ActivityManager: App crashed! Process: com.xtc.watch 二、错误分析 进入File.java查看代码, /** * Constructs a new File using the path of the specified URI. {@code uri} * needs to be an absolute and hierarchical Unified Resource Identifier with * file scheme and non-empty path component, but with undefined authority, * query or fragment components. * * @param uri * the Unified Resource Identifier that is used to construct this * file. * @throws IllegalArgumentException * if {@code uri} does not comply with the conditions above. * @see #toURI * @see java.net.URI */ public File(URI uri) { // check pre-conditions checkURI(uri); this.path = fixSlashes(uri.getPath()); } checkURI(URI uri)的源代码如下: private static void checkURI(URI uri) { if (!uri.isAbsolute()) { throw new IllegalArgumentException("URI is not absolute: " + uri); } else if (!uri.getRawSchemeSpecificPart().startsWith("/")) { throw new IllegalArgumentException("URI is not hierarchical: " + uri); } if (!"file".equals(uri.getScheme())) { throw new IllegalArgumentException("Expected file scheme in URI: " + uri); } String rawPath = uri.getRawPath(); if (rawPath == null || rawPath.isEmpty()) { throw new IllegalArgumentException("Expected non-empty path in URI: " + uri); } if (uri.getRawAuthority() != null) { throw new IllegalArgumentException("Found authority in URI: " + uri); } if (uri.getRawQuery() != null) { throw new IllegalArgumentException("Found query in URI: " + uri); } if (uri.getRawFragment() != null) { throw new IllegalArgumentException("Found fragment in URI: " + uri); } } 原来就是下面这一段代码抛出的异常,如果uri不是以file开头的就抛异常IllegalArgumentException(“Expected file scheme in URI: ” + uri), if (!"file".equals(uri.getScheme())) { throw new IllegalArgumentException("Expected file scheme in URI: " + uri); } 而我们的uri 是通过下面代码获取而来的 Uri downloadFileUri = manager.getUriForDownloadedFile(downId); File file = new File(new URI(downloadFileUri.toString())); 得到的uri信息为 content://downloads/my_downloads/12 因此就抛了该异常出来。 getUriForDownloadedFile(long id)源代码如下: /** * Returns the {@link Uri} of the given downloaded file id, if the file is * downloaded successfully. Otherwise, null is returned. *<p> * If the specified downloaded file is in external storage (for example, /sdcard dir), * then it is assumed to be safe for anyone to read and the returned {@link Uri} corresponds * to the filepath on sdcard. * * @param id the id of the downloaded file. * @return the {@link Uri} of the given downloaded file id, if download was successful. null * otherwise. */ public Uri getUriForDownloadedFile(long id) { // to check if the file is in cache, get its destination from the database Query query = new Query().setFilterById(id); Cursor cursor = null; try { cursor = query(query); if (cursor == null) { return null; } if (cursor.moveToFirst()) { int status = cursor.getInt(cursor.getColumnIndexOrThrow(COLUMN_STATUS)); if (DownloadManager.STATUS_SUCCESSFUL == status) { int indx = cursor.getColumnIndexOrThrow( Downloads.Impl.COLUMN_DESTINATION); int destination = cursor.getInt(indx); // TODO: if we ever add API to DownloadManager to let the caller specify // non-external storage for a downloaded file, then the following code // should also check for that destination. if (destination == Downloads.Impl.DESTINATION_CACHE_PARTITION || destination == Downloads.Impl.DESTINATION_SYSTEMCACHE_PARTITION || destination == Downloads.Impl.DESTINATION_CACHE_PARTITION_NOROAMING || destination == Downloads.Impl.DESTINATION_CACHE_PARTITION_PURGEABLE) { // return private uri return ContentUris.withAppendedId(Downloads.Impl.CONTENT_URI, id); } else { // return public uri String path = cursor.getString( cursor.getColumnIndexOrThrow(COLUMN_LOCAL_FILENAME)); return Uri.fromFile(new File(path)); } } } } finally { if (cursor != null) { cursor.close(); } } // downloaded file not found or its status is not 'successfully completed' return null; } 三、错误解决 将之前查找下载好的apk文件的代码 Uri downloadFileUri = manager.getUriForDownloadedFile(downId); File file = new File(new URI(downloadFileUri.toString())); 改为通过downId来查询DownloadManager下载的数据库的记录,然后查找本地文件的路径,如下所示: Cursor c = manager.query(new DownloadManager.Query().setFilterById(downId)); if(c != null){ c.moveToFirst(); int fileNameIdx = c.getColumnIndex(DownloadManager.COLUMN_LOCAL_FILENAME); String fileName = c.getString(fileNameIdx); File file = new File(fileName); LogUtil.d(TAG, "安装文件:" + file.getAbsolutePath()); c.close(); } 安装apk的代码由 //自动安装apk Intent install = new Intent(Intent.ACTION_VIEW); install.setDataAndType(downloadFileUri, "application/vnd.android.package-archive"); install.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(install); 改为 //自动安装apk Intent install = new Intent(Intent.ACTION_VIEW); //install.setDataAndType(downloadFileUri, "application/vnd.android.package-archive"); install.setDataAndType(Uri.parse("file://" + fileName.toString()), "application/vnd.android.package-archive"); install.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(install); 这样通过查询本地真实的下载好apk的真实本地路径,然后再进行安装的话就不会报异常了。 参考文章: http://blog.csdn.net/q445697127/article/details/40537945 http://www.xuebuyuan.com/2163407.html http://www.2cto.com/kf/201502/376975.html 作者:欧阳鹏 欢迎转载,与人分享是进步的源泉! 转载请保留原文地址:http://blog.csdn.net/ouyang_peng/article/details/53404379

优秀的个人博客,低调大师

Go 服务中 context.WithCancel 泄漏的排查与修复

线上一个 Go 写的推送服务运行几天后 goroutine 数持续上涨,内存也跟着涨,但 CPU 没什么异常。用 pprof 看 goroutine 堆栈,发现大量 goroutine 卡在 context 的 Done channel 等待上。这些 goroutine 都来自同一个处理链:HTTP handler 里用 context.WithCancel 派生了子 context,传给下游的异步任务,但某个错误分支直接 return 了,没有调用 cancel。父 context 在请求结束时被取消,但子 context 的 cancel 函数没执行,它内部的 goroutine 就永远等不到退出信号。这个问题在带超时、带取消传播的并发任务里很常见,尤其是派生 context 后交给 goroutine 或连接池使用的场景。下面从复现入手,看泄漏怎么产生,以及怎么用 go vet 和代码结构把它堵住。 先写一段能稳定暴露问题的代码。假设我们有一个发送任务,需要在主流程之外异步上报结果,用 context 控制生命周期: ```go func handle(ctx context.Context, job Job) error { taskCtx, cancel := context.WithCancel(ctx) go reportAsync(taskCtx, job) if err := doSend(ctx, job); err != nil { return err // 这里直接返回,cancel 永远不会被调用 } cancel() return nil } func reportAsync(ctx context.Context, job Job) { select { case 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5201.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5202.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5203.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5204.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5205.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5206.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5207.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5208.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5209.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5210.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5211.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5212.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5213.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5214.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5215.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5216.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5217.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5218.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5219.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5220.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5221.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5222.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5223.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5224.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5225.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5226.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5227.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5228.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5229.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5230.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5231.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5232.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5233.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5234.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5235.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5236.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5237.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5238.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5239.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5240.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5241.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5242.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5243.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5244.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5245.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5246.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5247.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5248.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5249.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5250.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5251.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5252.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5253.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5254.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5255.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5256.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5257.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5258.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5259.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5260.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5261.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5262.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5263.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5264.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5265.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5266.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5267.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5268.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5269.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5270.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5271.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5272.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5273.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5274.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5275.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5276.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5277.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5278.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5279.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5280.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5281.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5282.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5283.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5284.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5285.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5286.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5287.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5288.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5289.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5290.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5291.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5292.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5293.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5294.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5295.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5296.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5297.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5298.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5299.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5300.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5301.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5302.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5303.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5304.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5305.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5306.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5307.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5308.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5309.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5310.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5311.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5312.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5313.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5314.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5315.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5316.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5317.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5318.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5319.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5320.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5321.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5322.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5323.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5324.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5325.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5326.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5327.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5328.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5329.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5330.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5331.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5332.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5333.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5334.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5335.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5336.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5337.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5338.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5339.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5340.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5341.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5342.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5343.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5344.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5345.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5346.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5347.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5348.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5349.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5350.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5351.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5352.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5353.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5354.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5355.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5356.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5357.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5358.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5359.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5360.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5361.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5362.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5363.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5364.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5365.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5366.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5367.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5368.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5369.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5370.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5371.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5372.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5373.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5374.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5375.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5376.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5377.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5378.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5379.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5380.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5381.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5382.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5383.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5384.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5385.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5386.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5387.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5388.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5389.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5390.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5391.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5392.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5393.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5394.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5395.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5396.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5397.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5398.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5399.html 推荐查看天气:http://www.tianqi98.com/jizhuanwan/5400.html

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册
修改密码
忘记密码